Question
There are 12 inches in a foot and 3 feet in a yard . Create a class named InchConversion. Its main() method accepts a value
There are 12 inches in a foot and 3 feet in a yard.
Create a class named InchConversion. Its main() method accepts a value in inches from a user at the keyboard, and in turn passes the entered value to two methods. One converts the value from inches to feet, and the other converts the same value from inches to yards.
Each method displays the results with appropriate explanation.
This is what I have but is not working:
import java.util.Scanner;
public class InchConversion { public static void main (String args[])
{ Scanner sc= new Scanner(System.in); int inches= sc.nextInt(); convertToFeet(inches); convertToYards(inches); }
public static void convertToFeet(int inches)
{ System.out.println("One Feet equals 12 inches"); double inch=inches;
System.out.println("So,"+inches+" inches equals "+inch/12+" feet"); }
public static void convertToYards(int inches)
{
System.out.println("One Yard equals 3 feets or 36 inches"); double inch=inches; System.out.println("So,"+inches+" inches equals "+inch/36+" yards");
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started