Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add a compareTo method to your FeetInches class, and anything else necessary but do NOT alter the toString method public class Lab7Num3 { public static

Add a compareTo method to your FeetInches class, and anything else necessary but do NOT alter the toString method

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

public FeetInches() { feet = 0; inches = 0; } public FeetInches(int f, int i) { feet = f + i/12; inches = i%12; } public void setFeet(int f){ feet = f; } public void setInches(int i){ feet = feet + i/12; inches = i%12; } public int getFeet(){ return feet; } public int getInches(){ return inches; }

public String toString() { return " Feet: " + feet + " Inches: " + inches ; } public int compareTo(FeetInches f) { } } public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); //declare an ArrayList //input the number of objects int howMany = keyboard.nextInt(); //loop howMany times, //each time input feet and inches, create a FeetInches object, add it to the ArrayList //sort the ArrayList //output the ArrayList } }

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

Step: 3

blur-text-image

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

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

More Books

Students also viewed these Databases questions