Write a program to compute the computer programming grades of 8 IT students.

Randomly create student numbers for each of the students and store each in an array.

The program should take the input of (validate the input where appropriate):

Names of Students and store them in an array.
Addresses of Students and store them in array.
Previous Grade for student. (A,B,C…..)
Marks for ‘Computer Programming Assignment 1’ (out of 25 marks)
Marks for ‘Computer Programming Assignment 2’ (out of 25 marks)
Marks for ‘Computer Programming Exam’ (out of 50 marks)
Based on the above input, work out the ‘Final Marks’ for Computer Programming (Assignment 1 + Assignment 2 + Exam) and store it in an array.

Then work out and display
The average Final Grade for the ‘Computer Programming’ class 2013.
The number of A’s, B’s, C’s, D’s, and Fails for ‘Computer Programming’ 2013
The name, address, previous grade, this year’s grade, percentage, and student number for each student.

Could somebody help me with this assignment please, I will show you what I have done so far

  int Studentnumbers[] = new int[8];//creates new array
        String StrStudentname[] = new String[8];//the array that will store 8 student surnames
        String StrStudentAdresses[] = new String[8];//the array that will store 8 student adresses
        String StrStudentPreviousGrade[] = new String[8];//the array that will store 8 student previous grades
        String Strmarkscomputerassignment[] = new String[8];

        for (int i = 0; i < Studentnumbers.length; i++) {

            double Studentnumber = Math.random() * 10000;
            double newnumber = Studentnumber;
            int RandomNewStudentnumber = (int) (newnumber);

            Studentnumbers[i] = RandomNewStudentnumber;
            System.out.println(Arrays.toString(Studentnumbers));

            StrStudentname[i] = JOptionPane.showInputDialog("Please enter student name");//popluates a students surname 8 times
            System.out.println(Arrays.toString(StrStudentname));//prints out student surname to the screen

            StrStudentAdresses[i] = JOptionPane.showInputDialog("Please enter student adresses");
            System.out.println(Arrays.toString(StrStudentAdresses));//prints out student adresses to the screen

            StrStudentPreviousGrade[i] = JOptionPane.showInputDialog(" Please enter previous grade");
            System.out.println(Arrays.toString(StrStudentPreviousGrade));
            String(StrStudentPreviousGrade));

Recommended Answers

All 9 Replies

Exactly what help do you need?

I need to work out and display
The average Final Grade for the ‘Computer Programming’ class 2013.
The number of A’s, B’s, C’s, D’s, and Fails for ‘Computer Programming’ 2013
The name, address, previous grade, this year’s grade, percentage, and student number for each student.

I'm not sure as to how to go about this, or whether my code the way it is now will alow me to input said information.

Your code for input looks OK. First complete that so you input all the required data. Thhen execute that and test it to confirm that your arrays have all the correct data in them.

Ok here it is, I realise the first code I submitted was missing various inputs.

package rob.halligan.assingment.pkg2;

/**
 *
 * @author Robbie
 */
import javax.swing.*;
import java.util.Arrays;
public class RobHalliganAssingment2 {




    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int Studentnumbers[] = new int[8];//creates new array
        String StrStudentfirstname [] = new String [8];//
        String StrStudentname[] = new String[8];//the array that will store 8 student names
        String StrStudentAdresses[] = new String[8];//the array that will store 8 student adresses
        String StrStudentPreviousGrade[] = new String[8];//the array that will store 8 student previous grades
        double  assignment1 [] = new double [8];
        double assignment2 [] = new double [8];
        double[] exam = new double [8];

        for (int i = 0; i < Studentnumbers.length; i++) {

            double Studentnumber = Math.random() * 10000;
            double newnumber = Studentnumber;
            int RandomNewStudentnumber = (int) (newnumber);

            Studentnumbers[i] = RandomNewStudentnumber;
            System.out.println(Arrays.toString(Studentnumbers));

            StrStudentfirstname [i] = JOptionPane.showInputDialog(null, " please enter first name"); // populates a students first name
            System.out.println(Arrays.toString(StrStudentfirstname));

            StrStudentname[i] = JOptionPane.showInputDialog(null,"Please enter Surname");//popluates a students surname 8 times
            System.out.println(Arrays.toString(StrStudentname));//prints out student surname to the screen

            StrStudentAdresses[i] = JOptionPane.showInputDialog(null, "Please enter adresses"); // populates a students address
            System.out.println(Arrays.toString(StrStudentAdresses));//prints out student adresses to the screen

            StrStudentPreviousGrade[i] = JOptionPane.showInputDialog(null,"Please enter previous grade"); // populates a students adress
            System.out.println(Arrays.toString(StrStudentPreviousGrade));

            assignment1 [i] = Double.parseDouble(JOptionPane.showInputDialog(null, "Please enter your marks for assignment 1")); // populates students marks
            System.out.println(Arrays.toString(assignment1));

            assignment2 [i] = Double.parseDouble(JOptionPane.showInputDialog(null, "Please enter your marks for assignment 2"));
            System.out.println(Arrays.toString(assignment2));

            exam [i] = Double.parseDouble(JOptionPane.showInputDialog(null, "please enter marks for exam"));
            System.out.println(Arrays.toString(exam));

puts

OK. Now you will need an array for the Final marks. You need a loop that adds values from the three Marks arraysfor each student and stores the total in the corresponding element of the final marks.

Okay thanks, would you mind giving me an example as to how I would go about creating the loop? The help is mych appreciated

Thye web is full of examples (just Google!), plus you must have aready covered this in your course.

Yeah we have but I struggle to understand it. Anyway thanks for your help :)

With so many general tutorials and examples on loops already written it makes no sense for me to write another one! BUt give it a try, and if you have specific questions or problems I'll try to help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.