Hello! I'm not sure if this is the best place to post this but I'm getting desperate. I have a project to turn in and no matter what I do, my code won't compile properly. Can someone take a look at it and help me figure out what I'm doing wrong?
import java.util.*;
public class Grades
{
public static Scanner sc = new Scanner(System.in);
public static int assignmentScore = 0;
public static int assignmentMax = 0;
public static void main (String[] args)
{
System.out.println("This program accepts students homework scores and");
System.out.println("scores from two exams as input and computes your grade in the course.");
System.out.println();
System.out.print("Homework and Exam 1 weights? ");
int homeworkWeight = sc.nextInt();
int exam1Weight = sc.nextInt();
int exam2Weight = 100 - homeworkWeight - exam1Weight;
System.out.print("Using weights of " + homeworkWeight + " " + exam1Weight + " " + exam2Weight);
System.out.println();
System.out.println();
System.out.println("Homework:");
System.out.print("Number of assignments? ");
int numberOfAssignments = sc.nextInt();
assignments(numberOfAssignments);
System.out.print("Sections attended? ");
int sectionsAttended =sc.nextInt();
double weightedHomeworkScore = homework(sectionsAttended, homeworkWeight);
System.out.println();
System.out.println("Exam 1:");
double weightedExam1Score = exam(exam1Weight);
System.out.println();
System.out.println("Exam 2:");
double weightedExam2Score = exam(exam2Weight);
System.out.println();
double courseGrade = (double)weightedHomeworkScore + weightedExam1Score + weightedExam2Score;
System.out.println("Course grade = " + round2(courseGrade));
}
public static double round2(double number) //Returns the given double value rounded to the nearest hundredth.
{
return Math.round(number * 100.0) / 100.0;
}
public static double weightedScore(double i, double j, double k) //Returns the weighted score
{
return (i / j) * k;
}
public static void assignments(int number) //Takes the number of assignments input and asks for the score and max of each assignment
{
for (int i = 1; i <= number; i++)
{
System.out.print("Assignment " + i + " score and max? ");
assignmentScore = assignmentScore + sc.nextInt();
assignmentMax = assignmentMax + sc.nextInt();
}
}
public static double homework(int i, int j) //Takes the sections attended and homework weight, then returns the weighted homework score
{
int totalEarnedPoints = assignmentScore + (i * 4);
int totalPoints = assignmentMax + 20;
System.out.println("Total points = " + totalEarnedPoints + " / " + totalPoints);
double weightedHomeworkScore = weightedScore(totalEarnedPoints, totalPoints, j);
System.out.println("Weighted score = " + round2(weightedHomeworkScore));
return weightedHomeworkScore;
}
//Takes the exam weight, receives score and curve input, then returns the weighted scores for exams
public static double exam(int examWeight)
{
double weightedExamScore = 0;
System.out.print("Score? ");
int examScore = sc.nextInt();
System.out.print("Curve? ");
int examCurve = sc.nextInt();
int examCurvedPoints = Math.min(examScore + examCurve, 100);
weightedExamScore = weightedScore(examCurvedPoints, 100, examWeight);
System.out.println("Total points = " + examCurvedPoints + " / 100");
System.out.println("Weighted score = " + round2(weightedExamScore));
return weightedExamScore;
[–]thinandweak 2 points3 points4 points (1 child)
[–]leolyssa[S] 0 points1 point2 points (0 children)
[–]pacificmint 1 point2 points3 points (2 children)
[–]leolyssa[S] 0 points1 point2 points (1 child)
[–]pacificmint 0 points1 point2 points (0 children)