Temperature Converter

/** * Converts Temperature * * Sejin Park * 09/07/17 */ import java.util.*; public class TempConverter { public static void main(String args[]){ boolean ProgramKill = true; while(ProgramKill){ Scanner sc = new Scanner(System.in); //This will scan the Temperature Number input Scanner scTemperature = new Scanner(System.in); //This will scan the Temperature of which it is converting from Scanner scContinue = new Scanner(System.in); //This will scan to continue the program System.out.println("Convert from Celsius or Fahrenheit?"); String Temperature = scTemperature.nextLine(); System.out.println("Please enter a temperature: "); double Num = sc.nextDouble(); if(Temperature.equals("Celsius")){ double ConvertedTemperature = (9.0/5.0 * Num) + 32.0; System.out.println(ConvertedTemperature); } if(Temperature.equals("Fahrenheit")){ double ConvertedTemperature = (Num + (-32.0)) * 5.0/9.0; System.out.println(ConvertedTemperature); } System.out.println("To continue converting temperature, say yes. If not say no."); String Continue = scContinue.nextLine(); if(Continue.equals("yes")){ continue; } if(Continue.equals("no")){ ProgramKill= false; } } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.