Write a program in pseudocode that inputs a Celsius degree in a double value and
ID: 669914 • Letter: W
Question
Write a program in pseudocode that inputs a Celsius degree in a double value and converts this value to Fahrenheit and displays the result. The formula for the conversions as a follows:
fahrenheit = (9/5) * celsius + 32
Code this program in Java
Do this code three times using three different formulas – comment out the ones not “running”
fahrenheit = (9/5) * celsius + 32
fahrenheit = (9/5.0) * celsius + 32
fahrenheit = (9.0/5) * celsius + 32
What happened using each different formula? Are the results different or the same? How?
Explanation / Answer
public class PrinterApp
{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
System.out.print("enter the celsius: ");
double Celsius=s.nextDouble();
double fahrenheit=((9/5)*Celsius)+32;
System.out.println("fahrenheit calculated using fahrenheit = (9/5) * celsius + 32: "+fahrenheit);
fahrenheit=((9/5.0)*Celsius)+32;
System.out.println("fahrenheit calculated using fahrenheit = (9/5.0) * celsius + 32: "+fahrenheit);
fahrenheit=((9.0/5)*Celsius)+32;
System.out.println("fahrenheit calculated using fahrenheit = (9.0/5) * celsius + 32: "+fahrenheit);
}
}
last two are giving correct answer and first one is giving wrong
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.