- Home >
- Programming >
- Java Programming help using scanner, if/else statements, and parameters.
Java Programming help using scanner, if/else statements, and parameters.
Question Description
I'm having problems with my homework: this is the specification (I have provided screenshots). I get a compiler error for the last line. Any help is appreciated. I'm posting what I have so far
import java.util.*;
public class Gradanator {
final int maximum = 100; // sets the cap to 100
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
intro();
double midterm = test("Midterm", console, 100);
double Final = test("Final", console, 100);
double homework = homework_score(console);
grade_report(midterm, Final, homework);
}
// this method introduces the program to the user
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();
}
// this method prompts the user to input details about the midterm or the final
// and calculates the scores
public static double test(String test,Scanner console, int maximum) {
System.out.print(test + ":" );
System.out.print("Weight(0-100)? ");
int weight = console.nextInt();
System.out.print("Score earned? ");
int score = console.nextInt();
System.out.print("Were scores shifted (1 = yes, 2 = no)? ");
int shift = console.nextInt();
if (shift == 1) {
System.out.print("Shift amount? ");
int shift_amount = console.nextInt();
score += shift_amount;
} else {
score = Math.min(score, maximum);
}
System.out.println("Total points = " + score + "/" + maximum);
double weighted = score_weight(score, weight, maximum);
System.out.print("Weighted score = ", weighted, weight);
return weighted;
System.out.println();
return score;
}
// this method prompts the user to input information about their homework
// and calculates the score
public static double homework_score(Scanner console) {
final int maximum_section_points = 30;
final int points_every_section = 5;
Sytem.out.println("Homework:");
System.out.print("Weight (0-100)? ");
int weight = console.nextInt();
System.out.print("Number of assignments? ");
int assignment_number = console.nextInt();
int homework_max = 0;
int homework_score = 0;
for (int i = 0; i < assignment_number; i++) {
System.out.print("Assignment" + (i + 1) + "score and max? ");
int score = console.nextInt();
int maximum_score = console.nextInt();
homework_max += maximum_score;
homework_score += score;
}
Sytem.out.print("How many sections did you attend? ");
int section = console.nextInt();
int section_points = Math.min((section * points_every_section), maximum_section_points);
System.out.println("Section points = " + section_points + "/" + maximum_section_points);
homework_score += section_points;
homework_max += maximum_section_points;
System.out.println("Total points: " + homework_Score + "/" + homework_max);
double weighted = score_weight(homework_score, weight, homework_max);
System.out.print("Weighted score = ", weighted, homework_max);
return weighted;
}
// this method will calculate the percentage that the user got
public static void grade_report(double midterm, double Final, double homework) {
double percent = midterm + Final;
System.out.println("Overall percentage = ", percent);
double minimum_grade;
String confirmation;
if (percent >= 85) {
minimum_grade = 3.0;
System.out.println("You did great!");
} else if (percent >= 75) {
minimum_grade = 2.0;
System.out.println("You were average.");
} else if (percent >= 60) {
minimum_grade = 0.7;
System.out.println("You did enouugh to pass.");
} else {
minimum_grade = 0.0;
System.out.println("Do better next time. Fighting!");
}
System.out.print("Your grade will be at least: ", minimum_grade);
System.out.println(confirmation);
}
public static double score_weight(int score, int weight, final int maximum_score) {
return ((double) score / double maximum_score) * double weight;
}
}
This question has not been answered.
Create a free account to get help with this and any other question!
Similar Content
A Brief History of Humankind Sapiens
by Yuval Noah Harari
The Great Gatsby
by Francis Scott Key Fitzgerald
The Hobbit
by J. R. R. Tolkien
Team of Vipers
by Cliff Sims
The Da Vinci Code
by Dan Brown
The Glass Palace
by Amitav Ghosh
The Metamorphosis
by Franz Kafka
Orphan Train
by Christina Baker Kline
Studypool values your privacy. Only questions posted as Public are visible on our website.
Brown University
1271 Tutors
California Institute of Technology
2131 Tutors
Carnegie Mellon University
982 Tutors
Columbia University
1256 Tutors
Dartmouth University
2113 Tutors
Emory University
2279 Tutors
Harvard University
599 Tutors
Massachusetts Institute of Technology
2319 Tutors
New York University
1645 Tutors
Notre Dam University
1911 Tutors
Oklahoma University
2122 Tutors
Pennsylvania State University
932 Tutors
Princeton University
1211 Tutors
Stanford University
983 Tutors
University of California
1282 Tutors
Oxford University
123 Tutors
Yale University
2325 Tutors