Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program written by - Student 216110115//
- import java.util.*;
- import java.lang.Math;
- import java.io.*;
- public class grading_system {
- //These are individual variables to store other things
- static String student_name;
- static int student_id;
- static int subject_no;
- static String subject_input_text;
- static int subject_input_string;
- //Variables for the grade percentages
- static float assignment_multi = 20.0F;
- static float attendance_multi = 10.0F;
- static float project_multi = 15.0F;
- static float midterm_multi = 25.0F;
- static float finalexam_multi = 30.0F;
- //Variables used to store the average
- static float assignment_average;
- static float attendance_average;
- static float project_average;
- static float midterm_average;
- static float finalexam_average;
- //Variables to represent user choices
- static int main_menu_choice = 0;
- public static void main(String[] args) {
- //in the main loop, if the user presses 1, go to grade output function, if the user presses 2, go to grade input function
- System.out.print("Select what you wish to do? (type 1 or 2) \n1. View grade results. \n2. Write grade results");
- if (main_menu_choice <= 3)
- {
- main_menu();
- }
- else if (main_menu_choice >= 0);
- {
- main_menu();
- }
- }
- public static void main_menu() {
- Scanner menu_choice = new Scanner(System.in);
- main_menu_choice = menu_choice.nextInt();
- if (main_menu_choice == 1)
- {
- view_grade();
- }
- else if (main_menu_choice == 2)
- {
- grade_input();
- }
- }
- public static void grade_input() {
- //get the student name
- Scanner console_studentname = new Scanner(System.in);
- System.out.println("Write down the name of this student: ");
- student_name = console_studentname.next();
- //Get the student's ID number
- System.out.println("Please enter the student's ID number: ");
- student_id = console_studentname.nextInt();
- //get the number of s ubjects
- Scanner console_subjectno = new Scanner(System.in);
- System.out.println("Write down the number of subjects the student takes");
- subject_no = console_subjectno.nextInt();
- /*Initialize the array, on the horizontal we have got the individual grades for
- each subject on the vertical we have got the individual subjects*/
- Object[][] Student_Scores = new Object [12][subject_no];
- //Start to collect all the data for the array.
- for (int i = 0; i < subject_no; i++) {
- //declare all the console scanners
- Scanner console_subject_name = new Scanner(System.in);
- Scanner console_assignment_grade = new Scanner(System.in);
- //The subject's name
- System.out.println("What is the name of this subject?");
- subject_input_text = console_subject_name.next();
- Student_Scores[0][i] = subject_input_text;
- //Collect the attendance score
- System.out.println("What was the student's attendance rate?");
- Student_Scores[1][i] = console_assignment_grade.nextInt();
- //Collect the assignment score
- System.out.println("What was the student's score for this assignment?");
- Student_Scores[2][i] = console_assignment_grade.nextInt();
- //Collect project grade
- System.out.println("What was the student's grade for the project?");
- Student_Scores[3][i] = console_assignment_grade.nextInt();
- //Collect midterm grade
- System.out.println("What was the student's grade for the midterm exams?");
- Student_Scores[4][i] = console_assignment_grade.nextInt();
- //Collect final exam grade
- System.out.println("What was the student's grade for the final exams?");
- Student_Scores[5][i] = console_assignment_grade.nextInt();
- System.out.println("Subject Completed... \n");
- }
- System.out.println("All subjects have been input \nWould you like to preview the entry? (Y/N)");
- grade_output(Student_Scores);
- }
- public static void grade_output(Object[][] array_student) {
- //write to file here
- System.out.println("Please check the information you put down is correct \n");
- System.out.println("Student's name is " + student_name);
- System.out.println("Number of subjects taken this semester: " + subject_no + "\n");
- for (int i = 0; i < subject_no; i++) {
- System.out.println ("==" + array_student[0][i] + "==");
- System.out.println("Attendance rate percentage: " + array_student[1][i]);
- attendance_average = ((int)array_student[1][i] / 100F)*attendance_multi;
- System.out.println("Attendance rate average: " + attendance_average + "\n");
- System.out.println("Assignment percentage: " + array_student[2][i]);
- assignment_average = ((int)array_student[2][i] / 100F)*assignment_multi;
- System.out.println("Assignment rate average: " + assignment_average + "\n");
- System.out.println("Project rate percentage: " + array_student[3][i]);
- project_average = ((int)array_student[3][i] / 100F)*project_multi;
- System.out.println("Project rate average: " + project_average + "\n");
- System.out.println("Midterm rate percentage: " + array_student[4][i]);
- midterm_average = ((int)array_student[4][i] / 100F)*midterm_multi;
- System.out.println("Midterm rate average: " + midterm_average + "\n");
- System.out.println("Final exam rate percentage: " + array_student[5][i]);
- finalexam_average = ((int)array_student[5][i] / 100F)*finalexam_multi;
- System.out.println("Final exam rate average: " + finalexam_average + "\n");
- System.out.println("Total Average: " + (attendance_average + assignment_average + project_average));
- System.out.println("\n");
- }
- System.out.println("Is the information you typed correct? (Y/N)");
- File file = new File(student_name + ".txt");
- }
- public static void view_grade() {
- //read a file from here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement