SHARE
TWEET

Temperature

a guest Feb 16th, 2020 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class Temperature {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner in = new Scanner(System.in);
  7.         double totalF = 0, totalC = 0, count = 0, c, f;
  8.         while (true) {
  9.             System.out.print("Enter Temp in Centigrade or <= -100.0 to quit: ");
  10.             c = in.nextDouble();
  11.             if (c <= -100)
  12.                 break;
  13.             f = (c * 1.8) + 32;
  14.             totalC += c;
  15.             totalF += f;
  16.             System.out.println("Temperature: F(" + f + ") C(" + c + ")");
  17.             ++count;
  18.         }
  19.         System.out.println("\nAverage: Centigrade(" + (totalC / count) + ") Average: Fahrenheit(" + (totalF / count) + ")");
  20.     }
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top