Question: Write a simple Java program that does the following: 1) Prompt the user to input three positive integers and store values in variables. a. For
Write a simple Java program that does the following:
1) Prompt the user to input three positive integers and store values in variables. a. For each integer input, test if a negative integer is entered by the user. If it is negative, change the value by multiplying the variable that holds it by -1 and print a warning to the user that you did so. b. Determine which variable holds the largest number, and assign it to a variable called largest. c. Determine which variable holds the smallest number, and assign it to a variable called smallest d. Assign the last variable to a variable called middle, or similar.
2) Prompt the user to input a character a or d and store in a variable a. If it is a output the 3 integers in ascending order: smallest, middle, largest. b. If it is d output the 3 integers in descending order: largest, middle, smallest. c. If the user inputs any other character, let them know that no other character is allowed and exit the program using the method System.exit(0);
3) Cast the largest integer to double and divide it by the sum of the two smaller numbers. a. Output the result of the division
4) Print out to the system console a single String using escape characters that outputs multiple lines with the following information, formatted the same as this example: a. your name b. your degree program c. a list of two of your classes, with the class number, name and days it meets lined up in columns using tabs as shown below: Alex Smith Computer Science CSI 2300 Object-Oriented Computing M/W/F PHY 1610 Fundamentals of Physics M/W/F
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
