For my homework problem, we enter number of students, then their names and numeric grades (0 - 100)
My problem is, I have to use a for loop for the number of students to enter their name and grade together. But if I do this I won't be able to separately print each name and grade.
I have a for loop that goes until the previously inputted number of students is reached, but this will not allow me to print all of the names and grades together at the end. The loop will ask for the students name and input, then the numeric grade and input. I cannot use arrays because we have not gotten to that point in our class so I will receive a 0 if I use them. I cannot use separate variables for each name and grade because the number of students is not a constant.
//loop input for all student names and their numeric grades
for(cntr = 0; cntr < numStudents; cntr++) {
System.out.print("Enter student name: ");
studentName = input.nextLine();
System.out.print("Enter " + studentName +"'s numeric grade: ");
numGrade = input.nextInt();
cleanUpStr = input.nextLine();
}
At the end I should be able to print each name followed by their grade.
Example:
Bob 50
bill 60
dill 90