
So what Im trying to do is write an array declaration to represent students names for a class and homework grades for each student. I have included my arrays for a declaration for 25 students names in a class and also a declaration for students tests grades in a class of 40. Now what I am trying to do is almost combine the two to create a larger array declaration. The declaration size does not have to be big, I only included 5 names but I can not figure out how to finish the code. Please HELP!
A) students? names for a class of 25 students
import java.util.Scanner;
public class Student
{
public static void main (String[] args)
{
Scanner scan = new Scanner (System.in);
String[] names = new String [15];
System.out.println ("Class Size : " + names.length);
for (int index = 0; index < names.length; index++)
{System.out.print ("Enter student " + (index+1) + " name :");
names[index] = scan.next();
}
System.out.println("Your student's are:");
for (int index = names.length-1; index>=0; index--)
System.out.print (names[index] + " ");
}
}
B) students? test grades for a class of 40 students
import java.util.Scanner;
public class Student
{
public static void main(String[] args)
{
final int STUDENTS = 40;
int[] grades = new int[STUDENTS];
Scanner scan = new Scanner(System.in);
for (int i=0; i { System.out.print("Enter grades for student " + (i+1) + ": "); grades[i] = scan.nextInt(); } System.out.println("\nStudent?s Grades"); System.out.println("--------------------"); for (int index = grades.length-1; index>=0; index--) } } C) students? names for a class and homework grades for each student public class Student { public static void main (String[] args) { String[] names = new String [] {"Jim", "Bobby", "Shawn", "Michael", "George"}; System.out.println ("Class Size : " + names.length); int[] grades = new int [] {80, 85, 90, 95, 100}; for (int i = 0; i < grades.length; i++) { } System.out.println("Your student's grades are:"); for (int index = names.length-1; index>=0; index--) System.out.print (names[index] + " " + grades[i]); } } } System.out.print (grades[index] + " ");
grades[i];
{
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.