I cannot get this Java program to run as the solution on the website says. I have 6 errors and was wondering if maybe you can fix them for me. //Class definition class InchesToFeet { //Main method definition public static void main(String[] args); { //Declare constant variables final int INCHES_IN_FOOT=12; int inchesLeft; //Compute number of feet in given inches feet=inches / INCHES_IN_FOOT; //Display the message System.out.println(inches+"inches is" + feet + "feet and"+inchesLeft+inches); } }
I cannot get this Java program to run as the solution on the website says. I have 6 errors and was wondering if maybe you can fix them for me.
//Class definition
class InchesToFeet
{
//Main method definition
public static void main(String[] args);
{
//Declare constant variables
final int INCHES_IN_FOOT=12;
int inchesLeft;
//Compute number of feet in given inches
feet=inches / INCHES_IN_FOOT;
//Display the message
System.out.println(inches+"inches is" + feet + "feet and"+inchesLeft+inches);
}
}
The correct code is given below.
Java code:
//Class definition
class InchesToFeet
{
//Main method definition
public static void main(String[] args)
{
//Declare constant variables
final int INCHES_IN_FOOT = 12;
int inchesLeft;
//Compute number of feet in given inches
int inches = 50; //let say value in inches is 50
int feet = inches / INCHES_IN_FOOT;
inchesLeft = inches - (feet * 12); //remaining inches
//Display the message
System.out.println(inches+" inches is " + feet + " feet and "+inchesLeft+" inches");
}
}
Screenshot of output is:
Step by step
Solved in 2 steps with 1 images