I am getting an error on the return isValid, and the validInput areas of my methods. how can i solve these problems? On the validInput error it says void is an invalid type for the variable, and the second validInput error says illegal modifier for parameters validInput only final is permitted. For the return isValid, it says void methods cannot have a return.
Code:
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
* @return
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
validInput();
//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
cTemp = fTemp * CS;
mDist = fDist * ME;
kWeight = pWeight * KL;
K = (fTemp + 459.67) * 5/9;
I = fDist * 12;
S = pWeight * 0.0714285714;
//Methods (error here)
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;
}
(error here) (error here on entry)
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");
}
(error here)
return isValid;
//Display Report
System.out.println(fTemp + " fahrenheit " + cTemp + " celsius " + K + " Kelvin ");
System.out.println(fDist + " feet " + mDist + " meters " + I + " Inches ");
System.out.println(pWeight + " pounds " + kWeight + " kilograms " + S + "Stones ");
}
}
private static void validInput() {
// TODO Auto-generated method stub
}
}
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]
My code currently looks like this;
A B
Project Title
Enter a Fahrenheit temperature (integer): 212
Enter a distance in feet (integer): 100
Enter a weight in pounds (integer): 100
212 fahrenheit 117.77777777777779 celsius 373.15000000000003 Kelvin
100 feet 30.48 meters 1200.0 Inches
100 pounds 45.36 kilograms 7.14285714Stones
So I know I dont have everything coded right so can anyone help as to how to get the results im supposed to get?