Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions

Question

Th ey told me Id have to write a lett er. Whos got time for that?

Answered: 1 week ago