Question: HELP IN JAVA: Write a program that inputs feet and inches, creates a FeetAndInches object, puts it in a Node, and then adds (prepends) these
HELP IN JAVA:
Write a program that inputs feet and inches, creates a FeetAndInches object, puts it in a Node, and then adds (prepends) these nodes to a list. Input is from the keyboard. Files Node.java and FeetAndInches.java have already been uploaded, you just have to write the main method.
public static void main(String[] args) { Scanner keyboard = new Scanner (System.in); int feet, inches; Node head=null; System.out.println("Please enter the number of feet and inches separated by space, enter 0 0 to quit"); feet = keyboard.nextInt(); inches = keyboard.nextInt(); while( ) { System.out.println("Please enter the number of feet and inches separated by space, enter 0 0 to quit"); feet = keyboard.nextInt(); inches = keyboard.nextInt(); } PrintList(head); } public static void PrintList(Node head) { Node curr=head; FeetAndInches m; while(curr !=null) {m= (FeetAndInches) curr.item; System.out.println(m); curr=curr.next; }//end while } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
