Question

In: Computer Science

Problem specifications: You are tasked with developing a complete temperature conversion program in Java. Your program...

Problem specifications:

You are tasked with developing a complete temperature conversion program in Java.

Your program should:

-prompt the user with the following menu:

-1-Convert Fahrenheit to Celcius

-2-Convert Celcius to Fahrenheit

-3-Quit Program

The menu must be coded in its own method.

-If user select option 1 then call a method that prompts the user to enter a value in degrees Fahrenheit and return it back to main.

-call a method that converts from Fahrenheit to Celcius

-call a method that displays the degrees in Fahrenheit and its equivalent in degress celcius.

-If user select option 2 then call a method that prompts the user to enter a value in degrees Celcius and return it back to main.

-call a method that converts from Celcius to Fahrenheit.

-call a method that displays the degrees in Celcius and its equivalent in degress celcius.

-if user select option three, abort the process and display a suitable message to that effect.

-the program must repeat the whole processes until user select 3.

-do not allow user to select a value other than 1, 2, or3 from the menu

-declare all needed variables inside the class (globally inside) and out of all methods including main().

Solutions

Expert Solution

import java.util.Scanner;

public class TemperatureConverterMenu {

   // returns the temperature in Celcius
   public static double toCelcius() {
       Scanner sc = new Scanner(System.in);
       System.out.println("Enter temperature in Fahrenheit: ");
       double fTemp=sc.nextDouble();
return (( 5 *(fTemp- 32.0)) / 9.0);

   }
   public static double toFahrenheit() {
       Scanner sc = new Scanner(System.in);
       System.out.println("Enter temperature in Celcius : ");
       double fTemp=sc.nextDouble();
       return (9.0/5.0)*fTemp + 32;
   }

   public static void main(String[] args) {
       int ch=0;
       Scanner sc = new Scanner(System.in);
       do{
           System.out.println("-1-Convert Fahrenheit to Celcius");
           System.out.println("-2-Convert Celcius to Fahrenheit");
           System.out.println("-3-Quit Program");
           ch=sc.nextInt();
           switch(ch){
           case 1:System.out.println(toCelcius());break;
           case 2:System.out.println(toFahrenheit());break;
           }
       }while(ch<3);
   }

}


Related Solutions

The client needs this program written in Java. Your team is tasked to create a program...
The client needs this program written in Java. Your team is tasked to create a program that converts Fahrenheit to Celsius. Fahrenheit temperature of 87.6 degrees. Convert it to Celsius, and display the temperature in both units. Your output should look similar to the following: Fahrenheit Temperature: 87.6 Celsius Temperature: 30.88
Program Specifications: You will be writing a Java program called ASCIIRabbit.java that will print the following...
Program Specifications: You will be writing a Java program called ASCIIRabbit.java that will print the following ASCII objects. There should be two blank lines between each shape and your output must match identically. Rabbit In A Hat -------------------- (^\ /^) \ V / (o o) ( (@) ) --------- | | | | | | _______ Rabbit Under A Hat -------------------- _______ | | | | | | --------- /\"/\ () * () ("")_("") Rabbit Wears A Hat ------------------ _______...
(java))Write a “Temperature Conversion” program. Declare choice, tempIn, tempOut variables Prompt the user with the messages...
(java))Write a “Temperature Conversion” program. Declare choice, tempIn, tempOut variables Prompt the user with the messages to choose: 1) Centigrade to Fahrenheit, 2) Fahrenheit to centigrade. Prompt the user for temperature value (tempIn) to convert. Calculate new tempOut. The calculation of the new tempOUT depends on choice 1 or 2 above.\ ( Lookup up the C to F formula online, loop up the F to C formula online ) Print out the the F and the C temps. Be sure...
Java programmers!!!! Complete the definition of the Tavunu class according to the specifications below and the...
Java programmers!!!! Complete the definition of the Tavunu class according to the specifications below and the JUnit4 test file given Background A tavunu is an imaginary Earth-dwelling being that looks a bit like a Patagonian Mara and lives in a non-gendered but hierarchical society. Most interactions among tavunu are negotiated with pava --- items of status used for bargaining. Pava is always traded whole; you can't trade half a pava. public class Tavunu { // See what to do }...
Write a program in Java and run it in BlueJ according to the following specifications: The...
Write a program in Java and run it in BlueJ according to the following specifications: The program reads a text file with student records (first name, last name and grade on each line) and determines their type (excellent or ok). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "all" - prints all student records (first name, last name, grade, type). "excellent" - prints students with grade > 89. "ok"...
A program of unit temperature conversion from celcius, ℃ to rankine, R is proposed. The program...
A program of unit temperature conversion from celcius, ℃ to rankine, R is proposed. The program should allow the user to input the temperature in ℃. The user must input correct range of rankine, i.e >0 R, if it is otherwise, the code must display as ‘out spec temperature range’. Using appropriate command, request the user to reinput the correct temperature range. (a.). Create an appropriate flow diagram and pseudocode of this program. (b.) Create a program of the proposed
I need to write this program in Python. Write a program that displays a temperature conversion...
I need to write this program in Python. Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. The tabular format of the result should include rows for all temperatures between 70 and 270 degrees Celsius that are multiples of 10 degrees Celsius (check the sample below). Include appropriate headings on your columns. The formula for converting between degrees Celsius and degrees Fahrenheit is as follow F=(9/5C) +32 Celsius Fahrenheit 70 158 80 176 90...
complete a pseudocode for the program specifications be sure to declare the contants and it contains...
complete a pseudocode for the program specifications be sure to declare the contants and it contains only 1 if-else statement you need a program that will calculate the net pay for the employees. Input consists of the employee’s first name, employee’s last name, hourly pay rate, hours worked. The gross pay is based on the hours worked. If the hours worked is over 40, then the overtime pay is one and a half times the hourly pay rate for all...
complete a pseudocode for the program specifications be sure to declare the contants and it contains...
complete a pseudocode for the program specifications be sure to declare the contants and it contains only 1 if-else statement You need a program that will calculate the cost of movie tickets. Input will consist of the customer’s name and age. The output is to consist of the customer’s name and ticket cost. If the age is 12 or less, the ticket cost is $5.00. If the age is over 12, the ticket cost is $8.95.
Temperature Converter Create a temperature conversion program that will convert the following to Fahrenheit: Celsius Kelvin...
Temperature Converter Create a temperature conversion program that will convert the following to Fahrenheit: Celsius Kelvin Newton Your program should take a character which represents the temperature to convert from and a value to be converted to using the following specification: C - Celsius K - Kelvin N - Newton In addition your program should take in the following character to exit the program: X - eXit the program The numeric input for your program should be of type double....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT