Make sure you take no input in this class and that it does


Create a Temperature class:
-Create methods to convert centigrade to fahrenheit and fahrenheit to centigrade.
-Make sure you take no input in this class and that it does not contain a main method.

Create a Temperature Demo program:
-Use your temperature class to create a temperature object.
-Ask the user for a value.
-Ask the user if the value is C or F.
-Display the user input and the result of the chosen operation to the screen.
-Repeat the program until the user chooses to quit.

My code below compiles correctly and meets all the requirements, but my methods need to be in a temperature class, not in the TemperatureDemo... Please help

my original code:

import java.util.Scanner;

public class TemperatureDemo {

public static void main(String[] args) {

char entry = 'e';

do {

Scanner in = new Scanner(System.in);

System.out.print("Enter a temperature: ");

double temp = in.nextDouble();

System.out.print("Centigrade or Fahrenheit? Enter c/f: ");

char unit = in.next().toLowerCase().charAt(0);

//methods

if(unit == 'f') {

System.out.println(temp + " Fahrenheit = " + (5 * (temp-32)/9) + " Centigrade");

}

else if(unit == 'c') {

System.out.println(temp + " Centigrade = " + (9 * (temp/5)+32) + " Fahrenheit");

}

else {

System.out.println("Invalid entry");

}

System.out.print("Enter q to quit or anything else to continue: ");

entry = in.next().toLowerCase().charAt(0);

} while(entry != 'q');

}

}

 

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Make sure you take no input in this class and that it does
Reference No:- TGS0661948

Expected delivery within 24 Hours