Question: Using Scanner ( System.in) Find the Oldest Age(HIGHT NUMBER) in Linked-list (Node) in JAVA I could not figure out that where should i write the

Using Scanner ( System.in) Find the Oldest Age(HIGHT NUMBER) in Linked-list (Node) in JAVA

I could not figure out that where should i write the method in this class (Find highest number with Scanner ( System.in )

-----------------------------------------

import java.util.Scanner;

public class CreateBicycleList {

private Scanner scanner;

private BNode start;

public CreateBicycleList( ) {

scanner = new Scanner(System.in);

}

public static void main(String[] args) {

CreateBicycleList program = new CreateBicycleList();

program.start();

}

public void start( ) {

buildList();

printoutList();

}

private void buildList() {

BNode tail, next;

start = null;

System.out.print("Owner name: ");

String name = scanner.next();

System.out.print("Owner age: ");

int age = scanner.nextInt();

System.out.print("Owner gender: ");

String gender = scanner.next();

if (!name.equalsIgnoreCase("QUIT")) {

start = new BNode(new Bicycle(name, age, gender), null);

tail = start;

while (true) {

System.out.print("Owner name: ");

name = scanner.next();

System.out.print("Owner age: ");

age = scanner.nextInt();

System.out.print("Owner gender: ");

gender = scanner.next();

if (name.equalsIgnoreCase("QUIT"))

break;

next = new BNode(new Bicycle(name, age, gender), null);

//create a new node

tail.setNext(next); //link the node as the last node

tail = next; //set tail point to the new last node

}

}

}

private void printoutList() {

BNode p = start;

while (p != null) {

Bicycle b = p.getItem();

System.out.println(b.getOwnerName());

System.out.println(b.getOwnerAge());

System.out.println(b.getOwnerGender());

p = p.getNext();

}

}

}

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!