Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

create a Java program that implements a menu system using only conditional statements and Loogs. The program should provide the user with a menu

create a Java program that implements a menu system using only conditional statements and Loogs. The program - Reverse the digits of the entered number and display the result. - Return to the main menu after displaying Menu: 1. Calculate Factorial 2. Check Prime Number 3. Find the Sum of Digits 4. Reverse a Number 5. Exit Menu: 1. Calculate Factorial. 2. Check Prime Number 3. Find the Sum of Digita 4. Reverse a Humber 5. Exit

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!

Step by Step Solution

3.44 Rating (144 Votes )

There are 3 Steps involved in it

Step: 1

Heres a Java program that implements the menu system with conditional statements and loops based on ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Information Security

Authors: Michael E. Whitman, Herbert J. Mattord

7th Edition

035750643X, 978-0357506431

More Books

Students also viewed these Programming questions

Question

How do sex and gender differ?

Answered: 1 week ago

Question

Explain the factors influencing wage and salary administration.

Answered: 1 week ago

Question

Examine various types of executive compensation plans.

Answered: 1 week ago

Question

1. What is the meaning and definition of banks ?

Answered: 1 week ago