Question: JAVA - The program first reads integer studentCount from input, representing the number of pairs of inputs to be read. Each pair has a string
JAVA
The program first reads integer studentCount from input, representing the number of pairs of inputs to be read. Each pair has a string and an integer, representing the student's name and age, respectively. One Student object is created for each pair and added to ArrayList studentList. Write the printStudents method in the Appointments class to call each Student object's print method.
Ex: If the input is:
Dax Ari Val
then the output is:
Student: Dax, Age:
Student: Ari, Age:
Student: Val, Age:
import java.util.Scanner;
import java.util.ArrayList;
public class Appointments
private ArrayList studentList new ArrayList;
public void inputStudentsScanner scnr
Student currStudent;
String currName;
int currAge;
int studentCount;
int i;
studentCount scnrnextInt;
for i ; i studentCount; i
currName scnrnext;
currAge scnrnextInt;
currStudent new Student;
currStudent.setNameAndAgecurrName currAge;
studentList.addcurrStudent;
Your code goes here
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
