Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

<p><br /><br />This is part of the code I have so far to get a total number of s

ID: 3640968 • Letter: #

Question

<p><br /><br />This is part of the code I have so far to get a total number of student's names and enter them into an array. For some reason <strong>the for loop isn't functioning properly and it isn't letting me get user input.</strong> I'm not seeing where my mistake is.<br /><br /><br />/**<br /> ***<br /> *<br /> ****** This program finds student names and enters in array<br /> ****** gets students 4 scores stores in an array and <br /> *********calculates the average for each student stores in an array<br /> ************ assigns student a letter grade based on score average<br /> */<br /><br /><br />import java.util.Scanner; // Needed for Scanner class<br /><br />public class StudentScores <br />{<br /><br /> public static void main(String args[]) <br /> {<br /> int studNum; // to store the total # of student scores to get<br /> <br /> Scanner keyboard = new Scanner(System.in);<br /> System.out.print("Enter the total number of students: ");<br /> studNum = keyboard.nextInt();<br /> <br /> String [] names = new String [studNum]; // Create array to hold student names; Arrray size based on user response above<br /> <br /> System.out.println("Enter the " + names.length + " student names: ");<br /> <br /> // Create for loop to fill array with names<br /> <br /> for (int index = 0; index &lt; names.length; index++)<br /> {<br /> System.out.println((index+1) +"'s name: ");<br /> names[index] = keyboard.nextLine();<br /> }<br /> <br /> <br /> <br /> }<br /> <br /> <br />}</p>

Explanation / Answer

please rate - thanks

see the red

/****** This program finds student names and enters in array
****** gets students 4 scores stores in an array and
*********calculates the average for each student stores in an array
************ assigns student a letter grade based on score average*/
import java.util.Scanner; // Needed for Scanner class
public class StudentScores
{ public static void main(String args[])
{int studNum; // to store the total # of student scores to get
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter the total number of students: ");
studNum = keyboard.nextInt();
keyboard.nextLine(); //flush the input buffer-it still has the enter from the integer that was just read
String [] names = new String [studNum]; // Create array to hold student names; Arrray size based on user response above
System.out.println("Enter the " + names.length + " student names: ");// Create for loop to fill array with names
for (int index = 0; index < names.length; index++)
{System.out.println((index+1) +"'s name: ");
names[index] = keyboard.nextLine();
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote