Question: Follow the started java code below the directions The starter code contains 2-3 formatting errors; all code (including code beyond the section that
Follow the started java code below the directions
![import java.util.Scanner; public class InchesToFeet { public static void main(String[] args) {](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/01/65ba642497fe4_14865ba64246f6db.jpg)
- The starter code contains 2-3 formatting errors; all code (including code beyond the section that students are required to complete to make the program functional) must comply with the formatting requirements.
- Complete the one print statement in the convert() method to compute and output the converted feet and inches as shown below.
- The program must be completed using only integer constants and variables. In other words, a decimal point should not be contained within the code.
- The programmer must complete the code with exactly one print statement in the convert() method.
- The programmer may not create additional variables.
SAMPLE OUTPUT:
=================================
Enter the number of inches:
14
14 inches is 1 feet, and 2 inches
==================
import java.util.Scanner; public class InchesToFeet { public static void main(String[] args) { }| // The 'convert()' method (called here from the main method) does all the //work! convert(); // This method asks the user for total inches and outputs the conversion to // feet and inches. public static void convert() { // Create a new Scanner to read in input from user Scanner scanner = new Scanner(System.in); // Prompt the user and then store their input in 'totalInches' System.out.println("Enter the number of inches: "); int totalInches = scanner.nextInt(); // Convert to feet and inches. // ex. If totalInches is 38, then the output would be: 38 inches is 3 feet, and 2 inches // The variable 'totalInches' is the number of inches the user has entered. // ??? INSERT YOUR CODE HERE } } // scanner.close(); //Close the scanner object.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
