subject
Engineering, 17.03.2020 22:10 hokamidat

Implement the following integer methods:

a)method Celsius return the Celsius equivalent of a Fahrenheit temperature, using the calculation
Celsius = 5.0/9.0*(Fahrenheit -32);

b) method Fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using the calculation
Fahrenheit = 9.0/5.0*(Celsius +32);

c)use the method from part (a) and (b) to write an application the enables the user either to enter a Fahrenheit temperature and display the Celsius equivalent or enter a Celsius temperature and display the Fahrenheit equivalent

This is the software program and the problem I am having is that I cannot get the program to give me the correct answer!

// Exercise 6.22: Convert. java
// Use a method to write an application to enable the user
// Either to enter a Fahrenheit and Celsius equivalent
// Or enter a Celsius temperature and display the Fahrenheit
// program use scanner class
import java. util. Scanner;

public class Convert
{
// convert temperatures
public void ConvertTemperature()
{
Scanner input = new Scanner( System. in );
double convert;
int selection;
double temp;
double converts;

do
{
// print and prompt for input from user
System. out. println("");
System. out. println( "Main Menu" );
System. out. println( "Enter 1 for Fahrenheit to Celsius equivalent " );
System. out. println( "Enter 2 for Celsius to Fahrenheit equivalent" );
System. out. println( "3 to Exit\n " );
System. out. print( "Selection: " );
selection = input. nextInt();

// converts celsius to fahrenheit
// converts fahrenheit to celsius

switch ( selection )
{
case 1:
System. out. println("Enter fahrenheit temperature: " );
temp = input. nextInt();
convert = celsius( temp );
System. out. printf("%f degrees F = %f degrees C\n",temp, convert );
break;

case 2:
System. out. println("Enter celsius temperature: " );
temp = input. nextInt();
converts = fahrenheit( temp );
System. out. printf("%f degrees C = %f degrees F\n", temp, converts );
break;

case 3:
break;

default:
System. out. println( "Invalid selection" );

} // end of switch
} while( selection != 3);
} // end of convertTemperatures
public static double fahrenheit(double celsius)
{
double fahrenheit;
fahrenheit = 9 / 5 * (celsius + 32);

return fahrenheit;
}

public static double celsius(double fahrenheit)
{
double celsius;
celsius = 5 / 9 * (fahrenheit - 32);

return celsius;
}

}

ansver
Answers: 3

Another question on Engineering

question
Engineering, 03.07.2019 15:10
Ahouse has the following electrical appliance usage (1) single 40w lamp used for 4 hours per day (2) single 60w fan used for 12 hours per day (3) single 200w refrigerator that runs 24 hours per day with compressor run 12 hours and off 12 hours find the solar power inverter size in watt with correction factor of 1.25.
Answers: 1
question
Engineering, 04.07.2019 18:10
Fluids at rest possess no flow energy. a)- true b)- false
Answers: 3
question
Engineering, 04.07.2019 18:10
Thermal stresses are developed in a metal when its a) initial temperature is changed b) final temperature is changed c) density is changed d) thermal deformation is prevented e) expansion is prevented f) contraction is prevented
Answers: 2
question
Engineering, 04.07.2019 18:10
Manometers are good examples of measuring instruments, nowadays they are not as common as before. a)-capacitive probe gauges b)-gravitational gauges deformation ) gauges d)-digital gauges
Answers: 1
You know the right answer?
Implement the following integer methods:

a)method Celsius return the Celsius equivalent...
Questions
Questions on the website: 13722361