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 key = new Scanner(System.in);
- double Centigrade, Fahrenheit, AvgF, AvgC, X , Y;
- Centigrade = 0;
- Fahrenheit = 0;
- X = 0;
- Y = 0;
- int i = 0;
- while (X > -100) {i++;
- System.out.println("");
- System.out.println(" Enter Temp in Centigrade or <= -100 to quit:");
- X = key.nextDouble();
- if (X <= -100) {i--;
- Centigrade = Centigrade - X ;
- AvgC = Centigrade/i;
- AvgF = Fahrenheit/i;
- System.out.print("Average Centigrade "); System.out.print(AvgC); System.out.print(" Average Fahrenheit "); System.out.print(AvgF);
- break;
- }
- Centigrade += X;
- Y = (9.0/5.0)*X + 32.0;
- Fahrenheit += Y;
- System.out.print("Temperature: F "); System.out.print(Y); System.out.print(" C "); System.out.print(X);
- }
- // do not touch these two down here :)
- }
- }
- //Centigrade to Fahrenheit configuration does work
- //Also, The exit of the while loop works as well.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement