Question: In java Complete this program by finishing the FeetInches class. import java.util.Scanner; public class Lab3Num2 { public static void main(String[] args) { Scanner keyboard =

In java Complete this program by finishing the FeetInches class.

import java.util.Scanner; public class Lab3Num2 {

public static void main(String[] args) { Scanner keyboard = new Scanner (System.in); System.out.println("Enter the number of feet as a whole number"); int feet1 = keyboard.nextInt(); System.out.println("Enter the number of inches as a whole number"); int inch1 = keyboard.nextInt(); FeetInches f = new FeetInches(feet1, inch1); System.out.println(f); f.setFeet(4); f.setInches(50); System.out.println(f); }

public class FeetInches { private int feet; private int inches;

public FeetInches() {//write the code for the default constructor here } public FeetInches(int f, int i) { //write the code for the constructor. //do not worry (for now) about negative values //but if the user tries to construct an object //with more than 12 inches the constructor //has to fix it. //For example 4 feet and 15 inches becomes 5 and inches 3 } //write the accessors and mutators here // note that setInches must also account for the parameter // being greater than 12 public String toString() { return feet + " feet and " + inches + " inches. "; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!