Computer science assignment help

computer science

Description

This is code I am working with for a class, and I am unable to get the desired Output required.  I am attaching screenshots of the output that needs to take place.  please comment on what you are doing so I can learn, I am still a novice at java.  Also,the program needs to be able to run exactly as the instructor says.


package asi7123;


import java.util.*;


public class Asi7123 {


public static void main(String[] args) {

Scanner keyboard = new Scanner(System.in);

String name;

int age;

String answer;

Person person;



do {


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

name = keyboard.nextLine();

while ("".equals(name)) {

System.out.println("ERROR: Please enter a name");

System.out.print("Enter Name: ");

name = keyboard.nextLine();

}


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

age = keyboard.nextLine();


// integer lineEntered;

// lineEntered = keyboard.nextLine();

// age = Integer.parseInt(lineEntered);

//

while (age System.out.println("ERROR: age must be 0 or higher");

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

//lineEntered = keyboard.nextLine();

//age = Integer.parseInt(lineEntered);

}


person = new Person();

person.name = name;

person.age = age;




System.out.println(person.output());


System.out.print("Another (Y/N): ");

answer = keyboard.nextLine();

if (!"Y".equals(answer)) {

System.out.print("ERROR: Enter Y or N: ");

answer = keyboard.nextLine();

}

if (!"N".equals(answer)) {

System.out.print("ERROR: Enter Y or N: ");

answer = keyboard.nextLine();

} while (answer.equals("Y"));

System.out.println("You entered " + person.size() + " names:");

for (Person elt : people) {

System.out.println(elt.output());

Download Attachments: 
JAVA PROGRAM CAP1.PNG 
JAVA PROGRAM CAP2.PNG


Related Questions in computer science category


Disclaimer
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.