temp conv

import java.util.*; /* * Adam Kovacs * September 7th 2017 */ /** * Write a short description of what the class does (one line) * @author (Adam Kovacs) * @version (9/8/17) */ public class Tempconversion//class header { public static void main(String args[]){ Scanner Temp= new Scanner(System.in); boolean keepGoing = true; //above is the boolean that will allow the program to continue or end while(keepGoing==true){ System.out.print("Enter temp"); int nextInt = Temp.nextInt(); //Here is the users textbox that allows them to enter the desired tempature to convert System.out.print("If C type 1 if F type 2"); int nextAdam = Temp.nextInt(); //here the user enters 1 or 2 based on if the tempature they have entered is Celcius of Farenheight if(nextAdam==1){ double F=(9.0/5 * nextInt) + 32; System.out.print(F); } else { double C=(nextInt + (-32)) * 5/9.0; System.out.print(C); } //above are the conversion eqations that the program runs when given the tempature and whether its C or F System.out.print("press 1 to continue or 2 to exit"); int cont = Temp.nextInt(); if(cont==2){ keepGoing=false; } // this allows the user to end or continue using the program }//end of while System.out.print("Thanks for using this app"); }//end of main method }//end of class

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.