Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help in java: Create an array to hold 10 FeetInches objects. Input is from the keyboard (20 ints). To get the correct output you

Please help in java:

Create an array to hold 10 FeetInches objects. Input is from the keyboard (20 ints). To get the correct output you MUST use this input: 56 34 4 67 3 4 45 5 11 21 84 45 44 5 8 11 23 2 20 19

This is what I have so far:

public static class FeetInches { private int feet; private int inches; public FeetInches() {//write the code for the default constructor here 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 static void main(String[] args) { Scanner keyboard = new Scanner(System.in); int feet = 0,inch=0; //create an array to hold 10 FeetInches objects FeetInches[] ft = new FeetInches [10];

System.out.println("Enter 20 integers: "); for(int i=0; i<10; i++) feet=keyboard.nextInt(); inch=keyboard.nextInt(); FeetInches f= new FeetInches(feet,inch); for(int i=0; i<10;i++){ System.out.println("Feet: "+f.getFeet()+ " "+ "Inches: "+f.getInches()); } } }

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

=+ a. The capitaloutput ratio is constant.

Answered: 1 week ago