Question

In: Computer Science

You are required to write an interactive JS program that prompts the user for three numbers...

You are required to write an interactive JS program that prompts the user for three numbers and then finds the sum, average, smallest, and the largest value of the numbers and prints the results labeling properly.

Solutions

Expert Solution

Executable Code:



// reading user input and parsing them to integers

num1 = parseInt(prompt("Enter the first number: "));

num2 = parseInt(prompt("Enter the second number: "));

num3 = parseInt(prompt("Enter the third number: "));

// calculating the sum

sum = num1 + num2 + num3;

// calculating the average

avg = sum / 3;

// determining the smallest

if (num1 < num2 && num1 < num3) {

    smallest = num1;

}

else if (num2 < num3 && num2 < num1) {

    smallest = num2;

}

else {

    smallest = num3;

}

// determining the largest

if (num1 > num2 && num1 > num3) {

    largest = num1;

}

else if (num2 > num3 && num2 > num1) {

    largest = num2;

}

else {

    largest = num3;

}

// displaying the results

console.log("Sum of the three numbers is:", sum);

console.log("Average of the three numbers is:", avg);

console.log("Smallest of the three numbers is:", smallest);

console.log("Largest of the three numbers is:", largest);

Sample Output:



Please don't hesitate to contact me if you have any queries or require any modifications :)
Do rate the answer if it was helpful thanks.


Related Solutions

You are required to write an interactive program that prompts the user for two integers X...
You are required to write an interactive program that prompts the user for two integers X and Y and performs the following tasks: Adds two numbers Subtracts Y from X Multiplies X and Y Divides X by Y Finds which numbers is larger X oy Y) Prints all the results (a , b, c, d, and e) Program requirements: -     The program should run as many times as the users wish -     The program should be fully documented. -   ...
You are required to write an interactive program that prompts the user for ten (10) real...
You are required to write an interactive program that prompts the user for ten (10) real numbers and performs the following tasks: Reads and stores the numbers into one-dimensional array called A. The program must use a function to perform this task. Prints the content of the array. Write a function to perform this task. Calculates the sum of the numbers. Use a function to perform this task. Find the average of the numbers. Utilize a function to perform this...
1. Write a Java program that prompts the user to enter three integer numbers. Calculate and...
1. Write a Java program that prompts the user to enter three integer numbers. Calculate and print the average of the numbers. 2. Write a Java program that uses a for loop to print the odd numbers from 1 to 20. Print one number per line in the command line window. 3. Write a program which asks the user to input the size of potatoe fries she would like to purchase, and based on the size, it will tell her...
Write a C program that prompts the user to enter three sets of five double numbers...
Write a C program that prompts the user to enter three sets of five double numbers each. (You may assume the user responds correctly and doesn’t enter non-numeric data.) The program should accomplish all of the following: a. Store the information in a 3×5 array. b. Compute the average of each set of five values. c. Compute the average of all the values. d. Determine the largest value of the 15 values. e. Report the results. Each major task should...
You will write a program that prompts the user to enter a 7-digit phone numbers, and...
You will write a program that prompts the user to enter a 7-digit phone numbers, and finds the 3- and 4-letter words that map to the phone number, according to the restrictions outlined earlier. A sample run: unixlab% java MapNumbers Enter name of dictionary file: words10683 Enter a test word (3 letters): cat Test word maps to 228 Enter telephone number (7 digits, no 0's or 1's, negative to quit): 2282273 Options for first 3 digits: act cat bat Options...
write this program in C++ Write a program that prompts a user for three characters. The...
write this program in C++ Write a program that prompts a user for three characters. The program must make sure that the input is a number 10 - 100 inclusive. The program must re prompt the user until a correct input is entered. Finally output the largest and the lowest value. Example 1: Input : 10 Input : 20 Input : 30 The largest is 30. The lowest is 10. Example 2: Input : 100 Input : 50 Input :...
C++ Program: Write a program that prompts the user for two numbers and stores them in...
C++ Program: Write a program that prompts the user for two numbers and stores them in signed integers. The program should then add those two numbers together and store the result in a signed integer and display the result. Your program should then multiply them by each other and store the result in another integer and display the result. Then do the same but with dividing the first number by the second. Display an error message to the screen if...
You must write a C program that prompts the user for numbers and multiplies them using...
You must write a C program that prompts the user for numbers and multiplies them using "a la russe" multiplication. No input is allowed at execution time (no command line input). The program MUST DISPLAY YOUR BANNER LOGO as part of a prompt to the user. A menu must allow the user to put in two numbers at the same time or each of two numbers one at a time. The valid range of values for each number is 0...
Write a test program that prompts the user to enter a sequence of numbers ending with...
Write a test program that prompts the user to enter a sequence of numbers ending with 0, and invokes this method to return the largest number in the input. Use inheritance and polymorphism approach. in java please
write a c++ program that prompts a user to enter 10 numbers. this program should read...
write a c++ program that prompts a user to enter 10 numbers. this program should read the numbers into an array and find the smallest number in the list, the largest numbers in the list the sum of the two numbers and the average of the 10 numbers PS use file I/o and input error checking methods
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT