Advertisement
Guest User

ARUSH_temperature

a guest
Jul 11th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3. public class temperature {
  4.  
  5.     public static void main(String[] args) {
  6.     Scanner key = new Scanner(System.in);
  7.     double Centigrade, Fahrenheit, AvgF, AvgC, X , Y;
  8.     Centigrade = 0;
  9.     Fahrenheit = 0;
  10.     X = 0;
  11.     Y = 0;
  12.     int i = 0;
  13.     while (X > -100) {i++;
  14.     System.out.println("");
  15.     System.out.println("  Enter Temp in Centigrade or <= -100 to quit:");
  16.         X = key.nextDouble();
  17.         if (X <= -100) {i--;
  18.             Centigrade = Centigrade - X ;
  19.             AvgC = Centigrade/i;
  20.             AvgF = Fahrenheit/i;
  21.             System.out.print("Average Centigrade  "); System.out.print(AvgC); System.out.print("  Average Fahrenheit  "); System.out.print(AvgF);
  22.             break;
  23.             }
  24.         Centigrade += X;
  25.         Y = (9.0/5.0)*X + 32.0;
  26.         Fahrenheit += Y;
  27.         System.out.print("Temperature: F  "); System.out.print(Y); System.out.print("  C  "); System.out.print(X);
  28.     }
  29.    
  30.  
  31.        
  32.        
  33.        
  34.        
  35.        
  36.        
  37.        
  38.        
  39.        
  40.        
  41.        
  42.        
  43.        
  44.        
  45. // do not touch these two down here :)     
  46.   }
  47. }
  48.  
  49. //Centigrade to Fahrenheit configuration does work
  50. //Also, The exit of the while loop works as well.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement