Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.68 KB | None | 0 0
  1. //Program written by - Student 216110115//
  2. import java.util.*;
  3. import java.lang.Math;
  4. import java.io.*;
  5.  
  6. public class grading_system {
  7.  
  8. //These are individual variables to store other things
  9. static String student_name;
  10. static int student_id;
  11. static int subject_no;
  12. static String subject_input_text;
  13. static int subject_input_string;
  14.  
  15. //Variables for the grade percentages
  16. static float assignment_multi = 20.0F;
  17. static float attendance_multi = 10.0F;
  18. static float project_multi = 15.0F;
  19. static float midterm_multi = 25.0F;
  20. static float finalexam_multi = 30.0F;
  21.  
  22. //Variables used to store the average
  23. static float assignment_average;
  24. static float attendance_average;
  25. static float project_average;
  26. static float midterm_average;
  27. static float finalexam_average;
  28.  
  29. //Variables to represent user choices
  30. static int main_menu_choice = 0;
  31.  
  32. public static void main(String[] args) {
  33. //in the main loop, if the user presses 1, go to grade output function, if the user presses 2, go to grade input function
  34. System.out.print("Select what you wish to do? (type 1 or 2) \n1. View grade results. \n2. Write grade results");
  35. if (main_menu_choice <= 3)
  36. {
  37. main_menu();
  38. }
  39. else if (main_menu_choice >= 0);
  40. {
  41. main_menu();
  42. }
  43.  
  44. }
  45.  
  46. public static void main_menu() {
  47. Scanner menu_choice = new Scanner(System.in);
  48. main_menu_choice = menu_choice.nextInt();
  49. if (main_menu_choice == 1)
  50. {
  51. view_grade();
  52. }
  53. else if (main_menu_choice == 2)
  54. {
  55. grade_input();
  56. }
  57. }
  58.  
  59.  
  60. public static void grade_input() {
  61. //get the student name
  62. Scanner console_studentname = new Scanner(System.in);
  63. System.out.println("Write down the name of this student: ");
  64. student_name = console_studentname.next();
  65.  
  66. //Get the student's ID number
  67. System.out.println("Please enter the student's ID number: ");
  68. student_id = console_studentname.nextInt();
  69.  
  70. //get the number of s ubjects
  71. Scanner console_subjectno = new Scanner(System.in);
  72. System.out.println("Write down the number of subjects the student takes");
  73. subject_no = console_subjectno.nextInt();
  74.  
  75. /*Initialize the array, on the horizontal we have got the individual grades for
  76. each subject on the vertical we have got the individual subjects*/
  77. Object[][] Student_Scores = new Object [12][subject_no];
  78.  
  79. //Start to collect all the data for the array.
  80. for (int i = 0; i < subject_no; i++) {
  81.  
  82. //declare all the console scanners
  83. Scanner console_subject_name = new Scanner(System.in);
  84. Scanner console_assignment_grade = new Scanner(System.in);
  85.  
  86. //The subject's name
  87. System.out.println("What is the name of this subject?");
  88. subject_input_text = console_subject_name.next();
  89. Student_Scores[0][i] = subject_input_text;
  90.  
  91. //Collect the attendance score
  92. System.out.println("What was the student's attendance rate?");
  93. Student_Scores[1][i] = console_assignment_grade.nextInt();
  94.  
  95. //Collect the assignment score
  96. System.out.println("What was the student's score for this assignment?");
  97. Student_Scores[2][i] = console_assignment_grade.nextInt();
  98.  
  99. //Collect project grade
  100. System.out.println("What was the student's grade for the project?");
  101. Student_Scores[3][i] = console_assignment_grade.nextInt();
  102.  
  103. //Collect midterm grade
  104. System.out.println("What was the student's grade for the midterm exams?");
  105. Student_Scores[4][i] = console_assignment_grade.nextInt();
  106.  
  107. //Collect final exam grade
  108. System.out.println("What was the student's grade for the final exams?");
  109. Student_Scores[5][i] = console_assignment_grade.nextInt();
  110.  
  111. System.out.println("Subject Completed... \n");
  112. }
  113.  
  114. System.out.println("All subjects have been input \nWould you like to preview the entry? (Y/N)");
  115. grade_output(Student_Scores);
  116. }
  117.  
  118. public static void grade_output(Object[][] array_student) {
  119. //write to file here
  120. System.out.println("Please check the information you put down is correct \n");
  121. System.out.println("Student's name is " + student_name);
  122. System.out.println("Number of subjects taken this semester: " + subject_no + "\n");
  123. for (int i = 0; i < subject_no; i++) {
  124. System.out.println ("==" + array_student[0][i] + "==");
  125. System.out.println("Attendance rate percentage: " + array_student[1][i]);
  126. attendance_average = ((int)array_student[1][i] / 100F)*attendance_multi;
  127. System.out.println("Attendance rate average: " + attendance_average + "\n");
  128. System.out.println("Assignment percentage: " + array_student[2][i]);
  129. assignment_average = ((int)array_student[2][i] / 100F)*assignment_multi;
  130. System.out.println("Assignment rate average: " + assignment_average + "\n");
  131. System.out.println("Project rate percentage: " + array_student[3][i]);
  132. project_average = ((int)array_student[3][i] / 100F)*project_multi;
  133. System.out.println("Project rate average: " + project_average + "\n");
  134. System.out.println("Midterm rate percentage: " + array_student[4][i]);
  135. midterm_average = ((int)array_student[4][i] / 100F)*midterm_multi;
  136. System.out.println("Midterm rate average: " + midterm_average + "\n");
  137. System.out.println("Final exam rate percentage: " + array_student[5][i]);
  138. finalexam_average = ((int)array_student[5][i] / 100F)*finalexam_multi;
  139. System.out.println("Final exam rate average: " + finalexam_average + "\n");
  140. System.out.println("Total Average: " + (attendance_average + assignment_average + project_average));
  141. System.out.println("\n");
  142. }
  143. System.out.println("Is the information you typed correct? (Y/N)");
  144. File file = new File(student_name + ".txt");
  145.  
  146. }
  147.  
  148. public static void view_grade() {
  149. //read a file from here
  150. }
  151.  
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement