Question

Create a menu-driven Java application that solves several math problems. The user will select a number,...

Create a menu-driven Java application that solves several math problems. The user will select a number, and the program will respond with a necessary data. When the user enters option 5, the program will end. Below is sample output for the program:

What would you like me to do?

1. Calculate area of a circle?

2. Convert Fahrenheit temperature to Celsius?

3. Convert miles to kilometer?

4. Convert inches to centimeter?

5. Exit program?

Please enter your option:

1 Enter the radius of a circle: 1.0

The area of a circle with radius 1.0 is 3.142

What would you like me to do?

1. Calculate area of a circle?

2. Convert Fahrenheit temperature to Celsius?

3. Convert miles to kilometer?

4. Convert inches to centimeter?

5. Exit program?

Please enter your option: 5

Good bye!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;
class GFG {
   public static void main (String[] args) {
   Scanner sc = new Scanner(System.in);
   double pi=3.14159265358979323;
int option;
do
{
System.out.println("What would you like me to do?\n1. Calculate area of a circle?\n2. Convert Fahrenheit temperature to Celsius?\n3. Convert miles to kilometer?\n4. Convert inches to centimeter?\n5. Exit program?\nPlease enter your option:");
option = sc.nextInt();
if(option==1)
{
System.out.println("Enter the radius of circle: ");
double radius=sc.nextDouble();
System.out.println(pi*radius*radius);
}
if(option==2)
{
System.out.println("Enter temperature in Fahrenheit:");
double temp=sc.nextDouble();
System.out.println((temp-32)*(5.0/9));
}
if(option==3)
{
System.out.println("Enter the miles: ");
double miles=sc.nextDouble();
System.out.println(miles*1.609);
}
if(option==4)
{
System.out.println("Enter the inches:");
double inches=sc.nextDouble();
System.out.println(inches*2.54);
}
}while(option!=5);
System.out.println("Good Bye!");
}
}

Add a comment
Know the answer?
Add Answer to:
Create a menu-driven Java application that solves several math problems. The user will select a number,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Menu-driven programs will display the menu options to the user and then prompt them for a...

    Menu-driven programs will display the menu options to the user and then prompt them for a menu choice. This program will display the following menu in the following format: Calculator Options: Calculate the area of a circle Calculate the area of a rectangle Calculate the area of a triangle Calculate the area of a trapezoid Calculate the area of a sphere Exit Enter your choice (1-6) Once the user enters a choice for the menu, the program should use a...

  • Write a C++ program that shows the following menu options and lets the user to convert...

    Write a C++ program that shows the following menu options and lets the user to convert from Metric to Imperial system: Converter Toolkit --------------------     1. Temperature Converter     2. Distance Converter     3. Weight Converter     4. Quit If the user enters 1, the program should ask for the temperature in Celsius and convert it to Fahrenheit If the user enters 2, the program should ask for the distance in Kilometer and convert it to Mile If the user...

  • Please use C++ and output have to look like that Create a menu driven C++ program...

    Please use C++ and output have to look like that Create a menu driven C++ program with functions. There must be four functions, calculating the size of area of circle, rectangle, triangle, and parallelogram. You are required to create those four functions and invoke them from the main program in order to reccive any credit. Please Submit: . A flowchart of your program with equations and expected results. 4 points) 2. Printout of your C++program with a heading comment, also...

  • C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have...

    C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have 2 Labels (each one of them assigned only to Celsius and Fahrenheit), 2 TextBoxes (each one of them assigned only to Celsius and Fahrenheit), only 1 Convert Button, 1 Clear Button, and 1 Exit Button. Also, 1 Error message label which will display the error messages. The application should only allow the user to enter the desired temperature just in one of the TextBoxes...

  • Can you help me to create this program, please? Prompt the user for the user for...

    Can you help me to create this program, please? Prompt the user for the user for a number of degrees in Fahrenheit as an int. That number should be passed to a function named ffocREFO. This function will do the necessary calculation to convert the passed temperature to degrees Celsius as a double. The function MUST have a void return type and have the following prototype: void ffccREF(double& celsius, int Faren); In your main, display both the entered temperature and...

  • IN JAVA…Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be...

    IN JAVA…Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be able to enter a Celsius temperature, click a button, and then see the equiva-lent Fahrenheit temperature. Use the following formula to make the conversion: F = (9/5)C + 32 F is the Fahrenheit temperature and C is the Celsius temperature. Instead of only converting from Celsius to Fahrenheit, also convert from Fahrenheit to Celsius depending on the user's choice. Some hints: Use JTextField and...

  • Design program so that it correctly meets the program specifications given below.   Specifications: Create a menu-driven...

    Design program so that it correctly meets the program specifications given below.   Specifications: Create a menu-driven program that finds and displays areas of 3 different objects. The menu should have the following 4 choices: 1 -- square 2 -- circle 3 -- right triangle 4 -- quit If the user selects choice 1, the program should find the area of a square. If the user selects choice 2, the program should find the area of a circle. If the user...

  • Astronomy helper Create an application that displays the following menu: select a planet 1. Mercury 2....

    Astronomy helper Create an application that displays the following menu: select a planet 1. Mercury 2. Venus 3. Earth 4. Mars 5. exit the program Enter your selection. When the user selects a planet from the menu, the program should display data about the planet's average distance from the sun, the planet's surface temperature. Use the following data in your program: Mercury Average distance from the sun ---------- 57.9 million kilometers Mass---------------3.31 x 10^23kg surface temperature------------ -173 to 430 degrees...

  • Write python program using IDLE Write a full program that asks the user to enter his/her...

    Write python program using IDLE Write a full program that asks the user to enter his/her name then repeatedly ask to enter the temperature in Fahrenheit and convert it to Celsius, the program should then prompt the user if he/she wants to continue or exit the program. The formula for the conversion is: °C = (°F - 32) x 5/9 The program should use a function for the conversion. An Example of a sample run should appear on the screen...

  • write in python idle Write full program that asks the user to enter his/her name then...

    write in python idle Write full program that asks the user to enter his/her name then repeatedly ask to enter the temperature in Fahrenheit and convert it to Celsius, the program should then prompt the user if he/she wants to continue or exit the program. The formula for conversion is: °C = (°F - 32) x 5/9 The program should use a function for the conversion. An Example of a sample run should appear on the screen like the text...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT