Engineering
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;
}

}

answer
Answers: 3

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, xboxdude06
Slip occurs via two partial dislocations because of (a) the shorter path of the partial dislocation lines; (b) the lower energy state through partial dislocations; (c) the charge balance.
Answers: 1
image
Engineering, 04.07.2019 18:20, sanchez626
Aheavily insulated piston-cylinder device contains 0.02 m3 of steam at 300 kpa and 200 °c. 1.2 mpa. d this process. team is now compressed in a reversible manner to a pressure of etermine the entropy change and the work done on the steam during this process
Answers: 1
image
Engineering, 04.07.2019 19:10, Destinationz
Asteam is contained in a rigid tank with a volume of 1 m3. initially, the pressure and temperature are 7 bar and 500 oc, respectively. the temperature drops due to cooling process. determine: (1) the temperature at which condensation begins in °c, (2) the fraction of the total mass that has condensed when the pressure decreased to 0.5 bar. (3) the volume in m3 occupied by saturated liquid at the final state?
Answers: 3
image
Engineering, 04.07.2019 19:10, nhester3401
Agas is compressed from vi 0.3 m, p 1 bar to of v2 0.1 m3, p2--3 bar. pressure and volume are related linearly during the process. for the gas, find the work, in kj.
Answers: 2
Do you know the correct answer?
Implement the following integer methods:

a)method Celsius return the Celsius equivalent...

Questions in other subjects:

Konu
Mathematics, 09.04.2021 23:20