Question: Please help in Java: Complete this program by finishing the FeetInches class. import java.util.Scanner; public class Lab2Num4 { public static class FeetInches { private int

Please help in Java:

Complete this program by finishing the FeetInches class.

import java.util.Scanner;

public class Lab2Num4 {

public static 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 4 feet and 15 inches, the constructor

//has to fix it so that feet becomes 5 and inches 3

}

//write the accessors and mutators here

public String toString()

{

return feet + " feet and " + inches + " inches. ";

}

}

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);

}

}

thanks!!

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!