Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can you please help me write a comment for each line. 16 19 21 6 import java.util.*; // Brings in the package java.util that has
Can you please help me write a comment for each line.
16 19 21 6 import java.util.*; // Brings in the package java.util that has class Random 7 public class Grades // This is the class and file name 8{ // Open curly bracket opens the class Grades 9 public static Scanner sc = new Scanner(System.in); //Declare scanner object, this is our scanner, required for 10 public static int assignmentScore = 0; //Declare global variables 11 public static int assignmentMax = 0; 12 public static void main (String[] args) //main method 13 { 14 System.out.println("This program accepts students homework scores and"); 15 System.out.println("scores from two exams as input and computes your grade in the course."); System.out.println(); 17 System.out.print("Homework and Exam 1 weights? "); 18 int homeworkWeight = sc.nextInt(); //read the variables that are input, example use what is currently in the 20 int exam1Weight = sc.nextInt(); int exam2Weight = 100 - homeworkWeight - examlWeight; 22 23 System.out.print("Using weights of " + homeworkWeight + + examlWeight + "" + exam2Weight); 24 System.out.println(); 25 System.out.println(); 26 System.out.println("Homework:"); 27 System.out.print("Number of assignments? "); //read the number of assignments 28 29 int numberOfAssignments = sc.nextInt(); 30 assignments(numberOfAssignments); 31 System.out.print("Sections attended? "); 32 int sections Attended Esc.nextInt(); 33 double weightedHomeworkScore = homework(sections Attended, homeworkWeight); System.out.println(); 35 System.out.println("Exam 1:"); 36 double weightedExam1Score = exam(examlWeight); System.out.println(); 38 System.out.println("Exam 2:"); 39 double weightedExam2Score = exam(exam2Weight); 34 37 System.out.println(); double courseGrade = (double)weightedHomeworkScore + weightedExam1Score + weightedExam Score; System.out.println("Course grade = round2(courseGrade)); } public static double round2(double number) // Returns the given double value rounded to the nearest hundredth. 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 return Math.round(number * 100.0) / 100.0; } public static double weightedScore(double i, double j, double k) //Returns the weighted score after all nums entered { return (i / j) * k; } public static void assignments(int number) //Asks for the score and max of each assignment { for (int i = 1; iStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started