TemperatureConverter

/** * Write a description of class TempConverter here. *This is a temperature converter from F to C * @author (Rahul Khullar) * @version (9/7/17) */ /** * */ import java.util.*; public class TempConverter { public static void main(String args[]) { int restarter = 1; while (restarter == 1){ Scanner scan = new Scanner(System.in); System.out.println("Please enter a temperature: "); double temp = scan.nextInt(); System.out.println("Please enter 1 or 2, for convertion to F or C"); int decider = scan.nextInt(); if (decider == 1){ temp = ((9.0/5 * temp) + 32); } else if (decider == 2){ temp = (((temp - 32) * 5)/9); } System.out.println(temp); System.out.println("Please enter 1 if you want to play again and 2 if you want to quit"); int decider2 = scan.nextInt(); if (decider2 == 1){ restarter = 1; } else if (decider2 == 2){ restarter = 2; } } } }

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.