Temperature Converter

import java.util.*; /** * Write a short description of what the class does (one line) * @author (Sebastian Garrubbo) * @version (9/8/17) */ public class Tempconverter { public static void main(String args[]){ Scanner Temp= new Scanner(System.in); boolean runAgain = true; while(runAgain==true){ System.out.println("Enter a temperature :"); int nextInt = Temp.nextInt(); System.out.println("If Celcius, type 1. If Farhenheit, type 2 :"); int nextTemp = Temp.nextInt(); if(nextTemp==1){ double F=(9.0/5 * nextInt) + 32; System.out.println(F + " degrees"); } else { double C=(nextInt + (-32)) * 5/9.0; System.out.println(C + " degrees"); } System.out.println(" Type 1 to continue, or 2 to exit :"); int cont = Temp.nextInt(); if(cont==2){ runAgain=false; } } System.out.println("Thank you! "); } }

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.