Write an interactive version of the InchesToFeet class that accepts the inches value from a user.
class InchesToFeetInteractive
{
public static void main(String[] args) {
// Modify the code below
final int INCHES_IN_FOOT = 12;
int inches = 86;
int feet;
int inchesLeft;
feet = inches / INCHES_IN_FOOT;
inchesLeft = inches % INCHES_IN_FOOT;
System.out.println(inches + " inches is " +
feet + " feet and " + inchesLeft + " inches");
}
}
//InchesToFeetInteractive.java import java.util.Scanner; public class InchesToFeetInteractive { public static void main(String[] args) { int inches; Scanner scanner = new Scanner(System.in); System.out.print("Enter number of inches: "); inches = scanner.nextInt(); InchesToFeet inchesToFeet = new InchesToFeet(inches); inchesToFeet.print(); } }
Get Answers For Free
Most questions answered within 1 hours.