0% found this document useful (0 votes)
144 views

JS Problem Solving Sheet

Uploaded by

Ahmed Smaha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
144 views

JS Problem Solving Sheet

Uploaded by

Ahmed Smaha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

JS Problem solving sheet

- Create an ordinary project folder with one index.html,


css folder (including 3 files: index.css, font awesome
css file, bootstrap css file), and one JS folder
including 2 files : bootstrap js file and your index.js
file.
- In your index.js file start to Code each question to
determine the goal of the question.
- Separate each code of each question with //Comment
the question number.
- Use console.log to print the output.
- After finishing, comment all the code( (Alt+a) ⇒ (ctrl+/)
) , ZIP your project folder and send it like an ordinary
assignment.
- Read carefully the following questions and wisely and start
to code the js code that determines the output.
—---------------------------------------------------------------------------
Using IF condition and loops only and without switch
case or array or object or any built in methods, code the
following questions:

1- Write a program that allows the user to enter a number then print it.

Ex: if the user enter 5 as a number ⇒ should log a 5


Ex: if the user enter 2 as a number ⇒ should log a 2

—---------------------------------------------------------------------------
2- Write a program that takes a number from the user then print yes if that
number can divide by 3 and 4 at the same time, otherwise print no.

Ex: if the user enters 12 as a number ⇒ should log a yes.


Ex: if the user enters 19 as a number ⇒ should log a no.

Hint: the number should have no remaining after division on 3 and 4 to


print yes.
—-------------------------------------------------------------------------------------------------
3- Write a program that allows the user to insert 2 integers then print the
max.

Ex: if the user enters 5 and 7 as numbers ⇒ should log a 7.


Ex: if the user enters 2 and 0 as numbers ⇒ should log a 2.
—---------------------------------------------------------------------------
4- Write a program that allows the user to insert an integer then print
negative if it is negative number, otherwise print positive.

Ex: if the user enters 5 as a number ⇒ should log a Positive.


Ex: if the user enters -2 as a number ⇒ should log a Negative.
—---------------------------------------------------------------------------
5- Write a program that takes 3 integers from the user then prints the max
element and the min element.

Ex: if the user enters 5 and 6 and 1 as numbers ⇒ should log a 6 is


the max and 1 is the min
Ex: if the user enters 10 and 10 and -1 as numbers ⇒ should log a 10
is the max and -1 is the min

—---------------------------------------------------------------------------
6- Write a program that allows the user to insert an integer number then
check If a number is even or odd.

Ex: if the user enters 5 as a number ⇒ should log an Odd.


Ex: if the user enters 6 as a number ⇒ should log an Even.

Hint: the number should have no remaining after division on 2 to print


Even.
—-------------------------------------------------------------------------------------------------
7- Write a program that take character from user then if it is vowel chars
(a,e,I,o,u) then print vowel otherwise print consonant
Note: lowercase and uppercase are important.

Ex: if the user enters a or A as a character ⇒ should log Vowel.


Ex: if the user enters s or S as a character ⇒ should log Consonant.
—---------------------------------------------------------------------------
8- Write a program that allows the user to enter a number then print all the
numbers starting from 1 to the user entered number.

Ex: if the user enter 5 as a number ⇒ should log a 1,2,3,4,5


Ex: if the user enter 7 as a number ⇒ should log a 1,2,3,4,5,6,7

Hint: Loops are helpful when you want to make pattern steps or when you
want to make a code repeat many times.
—-------------------------------------------------------------------------------------------------
9- Write a program that allows the user to insert an integer then print a
multiplication table up to 12.

Ex: if the user enters 5 as a number ⇒ should log 5,10,15,20,25.


Ex: if the user enters 3 as a number ⇒ should log 3,6,9,12,15,18,21.

Hint: Loops are helpful when you want to make pattern steps or when you
want to make a code repeat many times.
10- Write a program that allows the user to enter a number then print all the
only evens numbers starting from 1 to the user entered number.

Ex: if the user enters 5 as a number ⇒ should log 2,4.


Ex: if the user enters 13 as a number ⇒ should log 2,4,6,8,10,12.
—-------------------------------------------------------------------------------------------------
11- Write a program that allows the user to enter two numbers and print the
result to make the second number power the first number.

Ex: if the user enters 2 and 10 as a number ⇒ should log 1024.


Ex: if the user enters 4 and 3 as a number ⇒ should log 64.
—-------------------------------------------------------------------------------------------------
12- Write a program to enter marks of five subjects and calculate total,
average and percentage.
Note: The total subject mark is from 100 and user should be able to enter 5
numbers; each number presents a subject mark.
Ex: enter first mark: 60
enter second mark: 70
enter third mark: 68
enter fourth mark: 76
enter fifth mark: 92

Should log ( total : 366, average : 73.2 and percentage : 73.2%)

Ex: enter first mark: 95


enter second mark: 76
enter third mark: 58
enter fourth mark: 90
enter fifth mark: 89

Should log ( total : 408, average : 81.6 and percentage : 81.6%)

Hint: Loops are helpful when you want to make pattern steps or when you
want to make a code repeat many times.
—-------------------------------------------------------------------------------------------------
13- Write a program to input the month number and print the number of
days in that month.

Ex: if the user enters 10 as a number ⇒ should log 31 days.


Ex: if the user enters 6 as a number ⇒ should log 30 days.
—-------------------------------------------------------------------------------------------------
14- Write a program to enter marks of five subjects and find percentage
and grade.
Note: The total subject mark is from 100 and the grades ranges are :
A grade from 90 to 100,
B grade from 80 to 90,
C grade from 70 to 80,
D grade from 50 to 70
F grade under 50.
Ex: enter first mark: 60
enter second mark: 70
enter third mark: 68
enter fourth mark: 76
enter fifth mark: 92

Should log enter first mark: D and 60%


enter second mark: C and 70%
enter third mark: D and 68%
enter fourth mark: C and 76%
enter fifth mark: A and 92%

Ex: enter first mark: 95


enter second mark: 76
enter third mark: 58
enter fourth mark: 90
enter fifth mark: 89

Should log enter first mark: A and 95%


enter second mark: C and 76%
enter third mark: D and 58%
enter fourth mark: A and 90%
enter fifth mark: B and 89%

Hint: Loops are helpful when you want to make pattern steps or when you
want to make a code repeat many times.
—-------------------------------------------------------------------------------------------------
Using switch case only and without array or object or any
built in methods, code the following questions:

15- Write a program to input the month number and print the number of
days in that month.

Ex: if the user enters 10 as a number ⇒ should log 31 days.


Ex: if the user enters 6 as a number ⇒ should log 30 days.
—-------------------------------------------------------------------------------
16- Write a program that take character from user then if it is vowel chars
(a,e,I,o,u) then print vowel otherwise print consonant
Note: lowercase and uppercase are important.

Ex: if the user enters a or A as a character ⇒ should log Vowel.


Ex: if the user enters s or S as a character ⇒ should log Consonant.
—-------------------------------------------------------------------------------------------------
17- Write a program that takes 2 integers from the user then prints the max
element.

Ex: if the user enters 5 and 6 as numbers ⇒ should log a 6 is the


max.
Ex: if the user enters 10 and -1 as numbers ⇒ should log a 10 is the
max.

—-------------------------------------------------------------------------------------------------
18- Write a program that allows the user to insert an integer number then
check If a number is even or odd.

Ex: if the user enters 5 as a number ⇒ should log an Odd.


Ex: if the user enters 6 as a number ⇒ should log an Even.

Hint: the number should have no remaining after division on 2 to print


Even.
—-------------------------------------------------------------------------------------------------
19- Write a program that allows the user to insert an integer then print
negative if it is negative number, or print positive if it is a positive number or
zero if it is zero.

Ex: if the user enters 5 as a number ⇒ should log a Positive.


Ex: if the user enters -2 as a number ⇒ should log a Negative.
Ex: if the user enters 0 as a number ⇒ should log a Zero.
—-------------------------------------------------------------------------------------------------
20- Write a program to create Simple Calculator.

Ex: if the user enters 5 and 6 as numbers and + as character ⇒


should log 11.
Ex: if the user enters 10 and 2 as numbers and - as character ⇒
should log 8.
Ex: if the user enters 3 and 4 as numbers and * as character ⇒
should log 12.
Ex: if the user enters 12 and 6 as numbers and / as character ⇒
should log 2.

—-------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
Welcome to JS, wish all the best

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy