Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ** Filename: Temp.mash
- ** Author: Thanasi Poulos
- ** Purpose: Converting temperatures
- */
- import console;
- int bigloop = 1;
- int selection = 0;
- while(selection == 0){
- println("+------------------------+");
- println("| TEMPERATURE CONVERTER! |");
- println("| -BY- |");
- println("| THANASI POULOS |");
- println("| |");
- println("| 1. C -> F |");
- println("| 2. F -> C |");
- println("| 3. C -> K |");
- println("| 4. K -> C |");
- println("| 5. F -> K |");
- println("| 6. K -> F |");
- println("| 7. EXIT |");
- println("+------------------------+");
- print ("Make a selection: ");
- selection = readInt();
- while (selection == 1){
- print("Enter degrees C to convert to degrees F: ");
- double c=readDouble();
- println();
- double f=(c*9/5)+32;
- println(c + " degrees celcius equals " + f + " degrees fahrenheit.");
- println();
- print("Type \"menu\" to return to the main menu or \"exit\" to close the program: ");
- String response = readWord();
- String compare = "menu";
- boolean menu = equals(response, compare);
- if (menu == true){
- selection = 0;
- }else{
- selection = 7;
- }
- }
- while (selection == 2){
- print("Enter degrees F to convert to degrees C: ");
- double f = readDouble();
- println();
- double c = (f-32)*(5.0/9.0);
- println(f + " degrees farenheit equals " + c + " degrees celcius.");
- println();
- print("Type \"menu\" to return to the main menu or \"exit\" to close the program: ");
- String response = readWord();
- String compare = "menu";
- boolean menu = equals(response, compare);
- if (menu == true){
- selection = 0;
- }else if (menu == false){
- selection = 7;
- }
- }
- while (selection == 3){
- print("Enter degrees C to convert to degrees K: ");
- double c = readDouble();
- println();
- double k = c + 273.15;
- println(c + " degrees celcius equals " + k + " degrees kelvin.");
- println();
- print("Type \"menu\" to return to the main menu or \"exit\" to close the program: ");
- String response = readWord();
- String compare = "menu";
- String compare2 = "exit";
- boolean menu = equals(response, compare);
- if (menu == true){
- selection = 0;
- }else{
- boolean exit = equals(response, compare2);
- if (exit == true){
- selection = 7;
- }else{
- println("Incorrect Parameter.");
- selection = 7;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment