/** I have to use the scanner class (no alternatives), to record a dynamic amount of grades. I use the hasNext() method to get the next value on the same line. For some reason when I am done entering numbers and I press enter the curser waites on the next line and does not exit the program. I want to be able to exit the program once I have entered multable grades and then pressed enter. */
public void enterGrades()
{
Scanner scan = new Scanner(System. in);
ArrayList<Strin g> al = new ArrayList<Strin g>();
System.out.prin t("Enter grades: ");
while(scan.hasN ext())
{
al.add(scan.nex t() );
System.out.prin tln(al);
}
}
public void enterGrades()
{
Scanner scan = new Scanner(System. in);
ArrayList<Strin g> al = new ArrayList<Strin g>();
System.out.prin t("Enter grades: ");
while(scan.hasN ext())
{
al.add(scan.nex t() );
System.out.prin tln(al);
}
}
Comment