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

(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...
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"...
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.
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
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....
Problem statement: You are tasked with writing a simple program that will keep track of items...
Problem statement: You are tasked with writing a simple program that will keep track of items sold by a retail store. We need to keep track of the stock (or number of specific products available for sale). Requirements: The program will now be broken up into methods and store all the inventory in an ArrayList object. The program will be able to run a report for all inventory details as well as a report for items that are low in...
Problem statement: You are tasked with writing a simple program that will keep track of items...
Problem statement: You are tasked with writing a simple program that will keep track of items sold by a retail store. We need to keep track of the stock (or number of specific products available for sale). Requirements: The Food and Book items should inherit all the properties of the Product item in the previous assignment. Foods cannot be added to the inventory without an expiration date. Implement a toString method for Product, Food, and Book. Grading details: Correct usage...
Strategic Management - As a top manager for your firm you have been tasked with developing...
Strategic Management - As a top manager for your firm you have been tasked with developing criteria for your strategic management team to evaluate strategies for your organization. Based on what you have studied in class, what criteria would you use to conduct your analysis (i.e. in evaluating the external and internal environment and other factors). Please ground your reasoning/argument in the textbook and show me you can apply concepts from class. You may want to give an example to...
Write a JAVA program to display your complete names, your matric number and your course of...
Write a JAVA program to display your complete names, your matric number and your course of study, using the two access modifiers stated in (a) and (b) (a) Use static access modifier for the method declaration of the program class, also use class name Eee532MakeUp. Use any method name of your choice. (b) Use public access modifier for the method declaration of the program class, also use class name EceCourseJava. (2) Which of the programs in (a) or (b) is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT