create a Java program that implements a menu system using only conditional statements and Loogs. The...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
create a Java program that implements a menu system using only conditional statements and Loogs. The program should provide the user with a menu of options, allow them to choose an option, and then perform the corresponding action based on their choice. The nenu should keep looping until the user chooses to exit. For this lab, you are not allowed to create methods for the different tanka. Menu Options: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Functionality of Menu Options: 1. Calculate Factorial: - Prompt the user to enter a positive integer. - Continue asking for input if the user inputs a negative number. - Calculate and display the factoria of the entered number. - Return to the main menu after displaying the result. 2. Check Prime Number: - Prompt the user to enter a positive integer greater than 1. - Continue asking for input unti: a valid positive integer greater than 1 is provided. - Determine if the entered number is prine or not. - Display whether the number is prime or not.. - Return to the main menu after displaying the result. 3. Find the Sum of Digits: - Prompt the user to enter a positive integer with at least two digits. - Continue asking for input unti: a valid positive integer with at least two digits is provided. - Calculate and display the sum of the digits of the entered number. - Return to the main menu after displaying the result. 4. Reverse a Number: - Prompt the user to enter a positive integer with at least two digits. - Continue asking for input unti: a valid positive integer with at least two digits is provided. - Reverse the digits of the entered number and display the result. - Return to the main menu after displaying the result. 5. Exit: - Exit the program. Additional Requirements: - Handle invalid inputs gracefully (i.e., negative numbers, less than two digits) and display appropriate error messages. - Ensure that the program continues running until the user chooses to exit. - Use only conditional statements for menu option selection. - Use loops to control the flow of the program. - Do not create methods or functions for this assignment. - You can use methods from the Scanner and Math classes. Examples of its use: Invalid option Menu: 1. Calculate Factorial. 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: 9 Invalid choice. Please enter a valid option. Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: Option 1 Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number: 5. Exit Enter your choice: 1 Enter a positive integer: -5 Enter a positive integer: 5 Factorial of 5 is: 120 Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: Option 2 Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: 2 Enter a positive integer: -8 Enter a positive integer: 175 175 is not a prime number. Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: Option 3 Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number. 5. Exit Enter your choice: 31 Enter a positive integer with at least two digits: 5 Enter a positive integer with at least two digits: -125 Enter a positive integer with at least two digits: 125 Sum of digits is: 8 Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: Option 4 Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: 41 Enter a positive integer with at least two digits: 6 Enter a positive integer with at least two digits: -2545 Enter a positive integer with at least two digits: 2545 Reversed number is: 5452 Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: Option 5 Menu: 1. Calculate Factorial. 2. Check Prime Number 3. Find the Sum of Digita 4. Reverse a Humber 5. Exit Enter your choice: 5 Exiting the program. Goodbye! If your program terminates after each options, then it is not correct! create a Java program that implements a menu system using only conditional statements and Loogs. The program should provide the user with a menu of options, allow them to choose an option, and then perform the corresponding action based on their choice. The nenu should keep looping until the user chooses to exit. For this lab, you are not allowed to create methods for the different tanka. Menu Options: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Functionality of Menu Options: 1. Calculate Factorial: - Prompt the user to enter a positive integer. - Continue asking for input if the user inputs a negative number. - Calculate and display the factoria of the entered number. - Return to the main menu after displaying the result. 2. Check Prime Number: - Prompt the user to enter a positive integer greater than 1. - Continue asking for input unti: a valid positive integer greater than 1 is provided. - Determine if the entered number is prine or not. - Display whether the number is prime or not.. - Return to the main menu after displaying the result. 3. Find the Sum of Digits: - Prompt the user to enter a positive integer with at least two digits. - Continue asking for input unti: a valid positive integer with at least two digits is provided. - Calculate and display the sum of the digits of the entered number. - Return to the main menu after displaying the result. 4. Reverse a Number: - Prompt the user to enter a positive integer with at least two digits. - Continue asking for input unti: a valid positive integer with at least two digits is provided. - Reverse the digits of the entered number and display the result. - Return to the main menu after displaying the result. 5. Exit: - Exit the program. Additional Requirements: - Handle invalid inputs gracefully (i.e., negative numbers, less than two digits) and display appropriate error messages. - Ensure that the program continues running until the user chooses to exit. - Use only conditional statements for menu option selection. - Use loops to control the flow of the program. - Do not create methods or functions for this assignment. - You can use methods from the Scanner and Math classes. Examples of its use: Invalid option Menu: 1. Calculate Factorial. 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: 9 Invalid choice. Please enter a valid option. Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: Option 1 Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number: 5. Exit Enter your choice: 1 Enter a positive integer: -5 Enter a positive integer: 5 Factorial of 5 is: 120 Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: Option 2 Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: 2 Enter a positive integer: -8 Enter a positive integer: 175 175 is not a prime number. Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: Option 3 Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number. 5. Exit Enter your choice: 31 Enter a positive integer with at least two digits: 5 Enter a positive integer with at least two digits: -125 Enter a positive integer with at least two digits: 125 Sum of digits is: 8 Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: Option 4 Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: 41 Enter a positive integer with at least two digits: 6 Enter a positive integer with at least two digits: -2545 Enter a positive integer with at least two digits: 2545 Reversed number is: 5452 Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Enter your choice: Option 5 Menu: 1. Calculate Factorial. 2. Check Prime Number 3. Find the Sum of Digita 4. Reverse a Humber 5. Exit Enter your choice: 5 Exiting the program. Goodbye! If your program terminates after each options, then it is not correct!
Expert Answer:
Answer rating: 100% (QA)
Heres a Java program that implements the menu system with conditional statements and loops based on ... View the full answer
Related Book For
Principles Of Information Security
ISBN: 9780357506431
7th Edition
Authors: Michael E. Whitman, Herbert J. Mattord
Posted Date:
Students also viewed these programming questions
-
What are some strategies for building quality into projects? What are some types of documentation that must be maintained for projects? What are the characteristics of good documents?
-
Create a program called Fraction Class is the definition for a Fraction object. Classes contain Attributes (the data) and Behaviors (the methods). The Fraction Attributes A fraction is an object that...
-
A European 3-month call option on Bank W shares with exercise price of 50 is priced 6 and a similar call option with exercise price of 60 is priced 4. Calculate the net profit or loss on a long bull...
-
Power Company acquired 80 percent of Solar Company's outstanding common stock for $200,000 cash on January 2, 2021. The two companies continued to operate as separate entities after the combination....
-
A jet of water having a cross-sectional area of 4 in2 strikes the fixed blade with a speed of 25 ft/s. Determine the horizontal and vertical components of force which the blade exerts on the water....
-
During 2017, its first year of operations as a delivery service, Persimmon Corp. entered into the following transactions. 1. Issued shares of common stock to investors in exchange for $100,000 in...
-
A sketch of the arithmetic mean radius blade sections of an axial-flow water turbine stage is shown in Fig. P12.48. The rotor speed is \(1500 \mathrm{rpm}\). (a) Sketch and label velocity triangles...
-
Hammond Inc. has analyzed the setup time on its computer-controlled lathe. The setup requires changing the type of fixture that holds a part. The average setup time has been 135 minutes, consisting...
-
Calculate and interpret the present value of growth opportunities (PVGO): Here is a company's information: Share price $80 Expected earnings $5 Required return on shares 10%. Choose the best answer:...
-
(Allocating Parking Spots) You are the manager of a luxury apartment building whose parking garage contains 300 parking spots. Residents may choose to purchase a dedicated parking spot for $60,000...
-
A project is expected to create after-tax operating cash flows of $25,000 a year for three years. The initial investment for fixed assets is $50,000. These assets will be worthless at the end of the...
-
A project with expected NOI of $500 000 next year. NOI grow at 3% thereafter, forever. If the required rate of return 13 % and a new building cost is $ 4 000 000, what is the value of land? 2. A...
-
Chevy Corp. has common shares with a current total market value of $75,000,000, and a cost of equity of 29%. The company has total debt outstanding that has a market value of $60,000,000 and a cost...
-
On November 1st, 2020, Gracie Cosmetics took out a loan of 209,842 to build a new location by the town mall. The bank charges them an annual rate of 9% beginning on November 1st. Gracie Cosmetics...
-
Carlos has worked very hard through his career as a teacher and is contemplating an early retirement. He already has a pension in place commencing at retirement age but wants to cut back on his...
-
About 4% of homes have solar panels to produce electricity. A certain city has 2,400 homes. 13. Show that it is acceptable to use a Normal model for this situation. 14. What are the mean and standard...
-
Required information [The following information applies to the questions displayed below.] Laker Company reported the following January purchases and sales data for its only product. Units sold at...
-
You are a U.S. investor who purchased British securities for 2,000 one year ago when the British pound cost U.S. $1.50. What is your total return (based on U.S. dollars) if the value of the...
-
Recall this attribute as one where the ownership or control of information has legitimacy or authorization. Assess the scenario where a breach of possession does not always equate to a breach of...
-
I. Justify the facts that organizations that had remote access systems in place were far better equipped to handle the transformation of the workplace that was the result of the pandemic. II....
-
Detail how an enterprise information security policy (EISP) is also known as a general security policy, organizational security policy, IT security policy, or information security policy. This policy...
-
The tube is subjected to a torque of 750 N. m. Determine the amount of this torque that is resisted by the gray shaded section. Solve the problem two ways: (a) by using the torsion formula, (b) by...
-
The solid shaft has a diameter of 0.75 in. If it is subjected to the torques shown, determine the maximum shear stress developed in regions BC and DE of the shaft. The bearings at A and F allow free...
-
The solid shaft has a diameter of 0.75 in. If it is subjected to the torques shown, determine the maximum shear stress developed in regions CD and EF of the shaft. The bearings at A and F allow free...
Study smarter with the SolutionInn App