Write Code

Write a JavaScript program to:

Write a program to continue getting an integer number from the user until the user enters 0.  For each number entered, the program will output if it is over the average of all the numbers entered to that point. It will also tell for each number if it is an even number.  When a 0 is entered, the program will output how many numbers were above 50, and the total average.

Write a program to enter names and ages until the user enters stop for the name. For each person, if they are over 50, ask for which city they live in. If they are younger than 50, ask which state they live in. When stop is entered, the program will output how many people were over 50, and the percent of the total people who were above 50.

Write a program to get 10 numbers from the user, and then output what the highest number and the lowest number were. Also output the avererage

Write a program to enter pairs of numbers until the difference between the 2 numbers is exactly 5. For each pair of numbers, output the difference between the 2 numbers. When the loop is exited, output the average difference between the 2 numbers.

Write a program to get scores and ages from the user until the user enters a 0 for the age. If the person is over 65, then add 5 points to their score and output this fact. For all scores at this point, if they are now over 90, output this fact, and get the name of the person. If the user is under 12 years old, get this person’s name and output a message using this name (see below). At the end of the program, output the lowest initial score, the average initial score, how many people were under 12, and how many total bonus points were awarded for people over 65.
Example output
Enter score
66
Enter age
75
Your are over 65 and your new score is 80
Enter score
92
Enter age
44
You are over 90
What is your name?
Jim
Enter score
88
Enter age
33
Enter score
54
Enter age
11
What is your name?
Tim
Good job, Tim!
Enter score
0
Enter age
0
The lowest initial score is 44
The average initial score is 75
1 person under 12
A total of 5 bonus points were awarded

Write a program to get numbers from the user until a -1 is entered.  Your program will print out the second highest score.

Write a program to get numbers from the user until the user enters a -1.   Ignore all numbers until the first score bigger than 80 is entered. Print the average of all the scores that were entered after the first score greater than 80.

Write a program to enter 10 numbers from the user. Print the highest even number and the average of all the odd numbers.  (Hint.. use % to see if a number is even or odd)

Write a program to Enter numbers from the user until an even number larger than 100 is entered. For each score, tell if it is odd or even. When you exit the loop, print the average of all the odd numbers less than 80.

Write a program to enter numbers from the user until a -1 is entered.  Find the average of all the even numbers entered. Then continue to enter numbers until a -1 is entered again. Print the average odd score for the second group of scores.  Print the average of all the numbers from both groups.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>