Question: please help with this java assignment: Ken's office hours are getting really full, and a long line is forming outside his office each time. The

please help with this java assignment: Ken's office hours are getting really full, and a long line is forming outside his office each time. The students decide that they are too smart to simply line up, and decide on implementing a system. The system is a queue, but with some weird exceptions. When a student joins the back of the line, if they are younger or if their grade is lower than the person in front of them they can move up 1 spot, but only 1 spot. Input If a student is joining the line, the input format is the student's first name then a space then their age, then a space, then their grade. When Ken helps the next student in line, removing them from the queue, the input is next. When the input is done, the input is end. Output The output will be the order of the students currently in line. If the queue is empty, output the word empty. Example Dale 2398 Christian 17100 Zane 6587 Esther 2186 next Ellis 3299 Ashley 2295 end Example Output Zane 6587 Esther 2186 Dale 2398 Ashley 2295 Ellis 3299import java.util.ArrayList;
import java.util.Scanner;
public class kensOffice{
public static void main(String [] args){
Scanner input=new Scanner(System.in);
ArrayListofficeLine=new ArrayList<>(); //array to store each student in line
while(true){
String name=input.next();
if(name.equals("next")){
if(!officeLine.isEmpty()){//to avoid errors
officeLine.remove(0);
}
} else if (name.equals("end")){
break;
} else {
int age=input.nextInt();
int gpa=input.nextInt();
if(name.length()>=100){
System.out.println("Student name must be less than 100 characters");
break;
}
if(age>=250){
System.out.println("Student age cannot be more than 250 years.");
break;
}
while (gpa<1|| gpa>100){
System.out.println("Student grade cannot be less than 0 or more than 100");
gpa=input.nextInt();
}
Student student=new Student(name,age,gpa);
officeLine.add(student);
int i=officeLine.size()-1;
if(i>0){
Student presentStudent=officeLine.get(i-1);
//conditions to move up
if(student.age

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!