Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Temperature {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- double totalF = 0, totalC = 0, count = 0, c, f;
- while (true) {
- System.out.print("Enter Temp in Centigrade or <= -100.0 to quit: ");
- c = in.nextDouble();
- if (c <= -100)
- break;
- f = (c * 1.8) + 32;
- totalC += c;
- totalF += f;
- System.out.println("Temperature: F(" + f + ") C(" + c + ")");
- ++count;
- }
- System.out.println("\nAverage: Centigrade(" + (totalC / count) + ") Average: Fahrenheit(" + (totalF / count) + ")");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement