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 14:10
Amass of m 1.5 kg of steam is contained in a closed rigid container. initially the pressure and temperature of the steam are: p 1.5 mpa and t 240°c (superheated state), respectively. then the temperature drops to t2= 100°c as the result of heat transfer to the surroundings. determine: a) quality of the steam at the end of the process, b) heat transfer with the surroundings. for: p1.5 mpa and t 240°c: enthalpy of superheated vapour is 2900 kj/kg, specific volume of superheated vapour is 0. 1483 m/kg, while for t 100°c: enthalpy of saturated liquid water is 419kj/kg, specific volume of saturated liquid water is 0.001043m/kg, enthalpy of saturated vapour is 2676 kj/kg, specific volume of saturated vapour is 1.672 m/kg and pressure is 0.1 mpa.
Answers: 3
question
Engineering, 04.07.2019 16:10
The force on a cutting tool are 2600n vertically downward and 2100 horizontal. determine the resultant force acting on the tool and the angle at which it acts.
Answers: 1
question
Engineering, 04.07.2019 18:10
The temperature of air decreases as it is compressed by an adiabatic compressor. a)- true b)- false
Answers: 2
question
Engineering, 04.07.2019 18:10
The filament of an incandescent lamp has a temperature of 2000k. calculate the fraction of radiation emitted in the visible light band if the filament is approximated as blackbody
Answers: 2
You know the right answer?
Implement the following integer methods:

a)method Celsius return the Celsius equivalent...
Questions
question
English, 07.12.2020 17:00
Questions on the website: 13722363