Thursday, June 19, 2014

Elementary Programming; Exercise No. 1

Write a program that reads a Celsius degree in a double value from the console, then converts it to Fahrenheit and displays the result. The formula for the conversion is as follows:
fahrenheit = (9 / 5) * celsius + 32

Solution:
public static void main(String[] args) {
   Scanner s = new Scanner(System.in);
   double celcius, farenheit;

   System.out.print("Enter a value for the celcis:");
   celcius = s.nextDouble();

   farenheit = (9/5) * celcius + 32;

   System.out.print("The value of " + celcius + " degree celcius in farenheit is " + farenheit);
}

3 comments:

  1. I would love to see comments in each line as to what is its purpose in the code to make learning easier

    ReplyDelete
  2. i like this becouse it's easy to help you

    ReplyDelete

Author