slashshot007
Active Member
- Joined
- May 6, 2006
- Sythe Gold
- 0
- Messages
- 164
this is the first program i made by myself. i'm quite proud of it. constructive criticism is appreciated.
Code:
import java.util.Scanner;
public class tempurature {
public static void main( String [] args ){
short loop = 2;
while (loop == 2 ){
System.out.print( "If you would like to convert from Fahrenheit to Celsius, press 1 or,\n if you would like to convert Celsius to Fahrenheit, press 2: " );
Scanner input = new Scanner(System.in);
short stupid = input.nextShort();
if (stupid == 1){
System.out.print( "Enter Degrees Fahrenheit: " );
int f = input.nextInt();
double c = (5.0/9.0)*(f-32);
System.out.println( f + " Degrees Fahrenheit is equal to " + c + " Degrees Celsius.");
loop = 1;
} else if (stupid == 2){
System.out.print( "Enter Degrees Celsius: ");
int c = input.nextInt();
double f = (9.0/5.0)*c+32;
System.out.print( c + " Degrees Celsius is equal to " + f + " Degrees Fahrenheit." );
loop = 1;
} else{
System.out.println( "Please Try Again. \n") ;
loop = 2;
}
}
}
}




