Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Program Description: Here we focus on using parameters, returning values, and de

ID: 3663801 • Letter: P

Question

Program Description: Here we focus on using parameters, returning values, and developing interactive programs. You will be using a Scanner object for console input, so you will need to import java.util.*; into your program. This program uses student grades on homework and exams along with a “weighting” value for each to compute an overall course grade. This program accepts your homework scores and scores from two exams as input and computes your grade in the course.

Program Behavior Details: You may assume that the user enters valid input. For example, assume that the user enters a number of homework assignments no less than 1, and that the sum of category weights entered will be no more than 100. The weight of a particular category (homework, exam 1, or exam 2) will be non-negative but could be 0. You should handle the following two special cases of user input: • A student might receive extra credit on a particular assignment, so for example 22 / 20 is a legal assignment score. But the total points for homework are capped at the maximum possible. For example if a student receives 63 total points out of a maximum of 60, your program should cap this to 60 / 60. • The maximum score for an exam is 100. If the curved exam score exceeds 100, a score of 100 is used. Use the Math.max and Math.min methods to constrain numbers to a given range. Notice that all weighted scores and grades printed by the program are shown with no more than 2 digits after the decimal point. To achieve this, you may type the following method into your program and call it to round a double value to the nearest hundredth: // Returns the given double value rounded to the nearest hundredth. public static double round2(double number) { return Math.round(number * 100.0) / 100.0; } The following is an example usage of this method to print a variable named x: System.out.println("The rounded value of x is " + round2(x)); The code to compute the student's homework scores requires you to compute a cumulative sum. See section 4.1 of the textbook for more information on this technique.

A major part of this assignment is demonstrating that you understand parameters and return values. Therefore, use static methods that accept parameters and return values where appropriate for structure and to eliminate redundancy. For full credit, you must use at least 5 non-trivial methods other than main and round2.

Your main method should represent a summary of the overall program; the majority of the behavior should come from other methods. To fully achieve this goal, some of your methods will need to return values back to their caller. Each method should perform a coherent task and should not do too large a share of the overall work.

here is an example output

This program accepts your homework scores and scores from two exams as input and computes your grade in the course. Homework and Exam 1 weights? 50 20

Using weights of HW: 50 Exam1: 20 Exam2: 30

Homework: Number of assignments? 3

Assignment 1 score and max? 14 15

Assignment 2 score and max? 16 20

Assignment 3 score and max? 19 25

Forum posts? 4

Total points = 65 / 80

Weighted score = 40.63

Exam 1:

Score? 81

Curve? 0

Total points = 81 / 100

Weighted score = 16.2

Exam 2:

Score? 95

Curve? 10

Total points = 100 / 100

Weighted score = 30.0

Course grade = 86.83

Explanation / Answer

import java.util.*;

public class Grades {
public static void main (String[] args) {

intro();

Scanner console = new Scanner(System.in);

int totalScoreMain = totalScore(score, curveNumber);
double weightedScoreMain = weightedScore(weight, score, curveNumber);
double weightedScore2Main = weightedScore2(weight2, sections, sumScore);

for(int i = 1; i <= 2; exam++); {
System.out.println("Exam i");
exam();
}
homework();
}

public static void intro () {

System.out.println("This program reads exam/homework scores");
System.out.println("and reports your overall course grade.");
System.out.println();
}


public static void exam () {

System.out.print("What is its weight (0-100)?");
double weight = console.nextInt();
System.out.print("Score earned?");
int score = console.nextInt();
System.out.print("Was there a curve (1=yes, 2=no)?");
int curve = console.nextInt();
if (curve == 1) {
System.out.print("How much was the curve?");
int curveNumber = console.nextInt();
} else if (curve == 2) {
int curveNumber = 0;
}

totalScore(score, curveNumber);
weightedscore(weight, score, curveNumber);

System.out.println("Total points = " + totalScoreMain + "/" + "100");
System.out.println("Weighted score = " + weightedScoreMain + "/" + weight);
}

public static int totalScore (int score, int curveNumber) {

int totalScore = Math.min(score + curveNumber, 100);
return totalScore;
}

public static double weightedScore (int weight, int score, int curveNumber) {

double weightedScore = (score + curveNumber) * weight/100;
return weightedScore;
}

public static void homework () {

System.out.print("What is its weight (0-100)?");
int weight2 = console.nextInt();
System.out.print("Number of assignments?");
int number = console.nextInt();
int sumScore = 0;
int sumMax = 0;

for(int i = 1; i <= number; i++) {
System.out.println("Assignment " + i + "score and max?");
int aScore = console.nextInt();
int aScoreMax = console.nextInt();

sumScore = sumScore + aScore;
sumMax = sumMax + aScoreMax; }

System.out.print("How many sections attended?");
int section = console.nextInt();
int sections = Math.min(3 * section, 20);
System.out.println("Section points = " + sections);

weightedScore2(weight2, sections, sumScore);

System.out.println("Total points = " + (sections + sumScore) + "/" + sumMax);
System.out.println("Weighted score = " + weightedScore2 + "/" + weight2);
}


public static double weightedScore2(int weight2, int sections, int sumScore)
{

int weightedScore2 = weight2/100 * (sections + sumScore);
return weightedScore2;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote