SHARE
TWEET

Untitled

a guest Jun 17th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Description of Program    example: Tool to Determine [ . . . ]
  2. //Name
  3. //date
  4. //special requirements:
  5.  
  6. import java.util.Scanner;
  7.  
  8. public class Temperature {
  9.  
  10.     public static void main(String[] args) {
  11.         Scanner scan = new Scanner(System.in);
  12.    
  13.     double celsius, fahrenheit;
  14.     double input_total = 0;
  15.     double fahrenheit_total = 0, celcius_total = 0;
  16.     double fahrenheit_average, celcius_average;
  17.    
  18.     do {
  19.         System.out.print("Enter the Temperature in Centigrade or <= -100.0 to quit: ");
  20.         celsius = scan.nextInt();
  21.                
  22.        
  23.             if (celsius > -100)
  24.             {
  25.                 fahrenheit = ((9.0/5.0) * celsius + 32.0);
  26.  
  27.                 input_total ++;
  28.                
  29.                 fahrenheit_total = fahrenheit_total + fahrenheit;
  30.                
  31.                 celcius_total = celcius_total + celsius;
  32.                
  33.                 System.out.println("Temperature: F" + " (" + fahrenheit + ") " + "C" + " (" + celsius + ")");
  34.  
  35.             }      
  36.    
  37.         }
  38.    
  39.     while (celsius > -100);
  40.    
  41.     if (input_total > 0)
  42.     {
  43.         fahrenheit_average = (fahrenheit_total / input_total);
  44.         celcius_average = (celcius_total / input_total);
  45.     }
  46.     else
  47.     {
  48.         fahrenheit_average = 0;
  49.         celcius_average = 0;
  50.     }
  51.     System.out.printf("Average: Fahrenheit:(%.2f)\n", fahrenheit_average);
  52.     System.out.printf("Average: Centigrade:(%.2f)\n", celcius_average);
  53.        
  54.     scan.close();
  55.  
  56.     }  
  57.        
  58.        
  59. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top