JavaScript Exercise Set 2
Programming Questions
Q1) Average Checker
Given four values from the user, determine if they have an average of 80% or higher.
You should also check for Scholarships
An average of 90 to 94 (inclusively) → $2000
An average of 95 to 99 (inclusively) → $4000
Q2) When squirrels party?
When squirrels get together for a party, they like to have acorns.
A squirrel party is successful when the number of acorns is between 40 and 60, inclusively.
During the weekends, there is no need for acorns. The party is always fun.
Create a program that outputs if the party was successful depending on the user’s input.
Q3) Adding two values with restrictions
Create a program that adds two integer values of the user's input.
The sum cannot be within the range of 10,20 (excluding 20); therefore, the program should output “illegal parameters” for such operands.
Q4) Create a program to check if an integer is a perfect square.
For example:
Input of 25 is a perfect square
Input of 17 is not a perfect square
You may assume that all your inputs are positive integers.
Q5) Two Away from a Multiple of 10
Create a program such that when given a non-negative number input, output whether or not if the number is 2 away from a multiple of 10.
Q6) Pythagorean Triples
Write a program to check if values a, b, and c are Pythagorean triples such that a^2+b^2 = c^2
Note: First Input → a; Second Input → b; Third Input → c;
Note: a, b, c are BAD variable names.
Q7) Triangles
Create a program such that:
Determine if the three side length inputs of a triangle is a valid triangle.
Determine the type of the triangle given its side length (equilateral, isosceles, scalene)
Q8) Movie Going Program
Create a program that determines what ratings of movies you can watch based on your age.
Ages in 18+ can watch all ratings of movie
Ages in 13 to 17 can watch all movies except a rating of R
Ages in 0 to 12 will require parental guidance for PG-13
All ages can enjoy G rated movies
Last updated