Im doing a project and I need my project to convert fahrenheit to celsius to kelvin along with feet to meters to inches and pounds to kilograms to stones. Anyways Ive coded the project (not sure how right it is) and when I run it, it asks for the amounts for each equation but then terminates the project. How can i fix this?
import java.util.Scanner; public class Project2 { private static final Object False = null; private static final int number = 0; private static final int CS = 0; private static final int fTemp = 0; private static final int fDist = 0; private static final int ME = 0; private static final int pWeight = 0; private static final int KL = 0; /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //Declare constants final double CS = (5.0 / 9); final double ME = 0.3048; final double KL = 0.4536; //Declare variables Scanner input = new Scanner(System.in); String entry; int fTemp, fDist, pWeight; String Inputnumber = null; double cTemp, mDist, kWeight, K, I, S; System.out.println(" A B "); System.out.println(" Project Title "); //Get Input System.out.print("Enter a Fahrenheit temperature (integer): "); fTemp = input.nextInt(); System.out.print("Enter a distance in feet (integer): "); fDist = input.nextInt(); System.out.print("Enter a weight in pounds (integer): "); pWeight = input.nextInt(); } //Perform Conversions static int cTemp = fTemp * CS; static int mDist = fDist * ME; static int kWeight = pWeight * KL; static double K = (fTemp + 459.67) * 5/9; int I = fDist * 12; double S = pWeight * 0.0714285714; //Methods private static void validInput(int i, int j) { // TODO Auto-generated method stub boolean withinRange = true; if (i < 0 || i > 212); System.out.println("Out of range"); withinRange = false; } private static boolean validInput(String entry) { // TODO Auto-generated method stub boolean isValid = false; try { Integer.parseInt(entry); isValid = true; } catch (Exception ex) { System.out.println("Entered value is invalid"); } //Display Report System.out.println(fTemp + " fahrenheit " + cTemp + " celsius " + K + " Kelvin "); return isValid; } }
My project is suppose to look like this as the ending result:
Name
Project title
Enter a Fahrenheit temperature (integer) [0-212]: 212
Enter a distance in feet (integer) [0-100]: 100
enter a weight in pounds (integer) [0-100]: 100
212 Fahenheit is 100.0 Celsius and 373.150 Kelvin
100 Feet is 30.480 Meters and 1200.00 Inches
100 Pounds is 45.360 Kilograms and 7.143 Stones
Please enter a fahrenheit temperature (integer) [0-212]: abc
The entered temperature value is invalid.
Please enter a fahrenheit temperature (integer) [0-212]: 213
The entered value is out of range [0-212]