CSE 142, Spring 2014 Programming Assignment #4: Gradanator - 63378

Solution Posted by
jordanblink

jordanblink

Rating : (19)A+
Solution Detail
Price: $40.00
Request Description

CSE 142, Spring 2014 Programming Assignment #4: Gradanator 

This interactive program focuses on if/else statements, Scanner, and returning values. Turn in a file named

Gradanator.java. To use a Scanner for console input, you must import java.util.*; in your code. The program

prompts a student for grades on homework and two exams and uses them to compute the student's course grade.

Below is one example log of execution from the program. This program behaves differently depending on the user input; user

input is bold and underlined below to make it stand out. Your output should match our examples exactly given the same input.

(Be mindful of spacing, such as after input prompts and between output sections.) Look at the other example logs on the

course web site and on the next page to get more examples of the

program's behavior.

The program begins with an introduction message that briefly

explains the program. The program then reads scores in three

categories: midterm, homework and final. Each category is

weighted: its points are scaled up to a fraction of the 100 percent

grade for the course. As the program begins reading each category,

it first prompts for the category's weight.

The user begins by entering scores earned on the midterm. The

program asks whether exam scores were shifted, interpreting an

answer of 1 to mean “yes” and 2 to mean “no.” If there is a shift,

the program prompts for the shift amount, and the shift is added to

the user's midterm score. Exam scores are capped at a max of 100;

for example, if the user got 95 and there was a shift of 10, the score

to use would be 100. The midterm's “weighted score” is printed,

which is equal to the user's score multiplied by the exam's weight.

Next, the program prompts for data about the final. This behavior

is the same as the behavior for the midterm.

Next, the user enters information about his/her homework,

including the weight and how many assignments were given. For

each assignment, the user enters a score and points possible. Use a

cumulative sum as in textbook section 4.2.

Section attendance is included in the homework category. You should assume that each section attended is worth 3 points, up

to a maximum of 20 points. This means that section points are capped to 20 before they are added to the homework category.

Once the program has read the user information for both exams and homework, it prints the student's overall percentage earned

in the course, which is the sum of the weighted scores from the three categories, as shown below:

Solution Description
import java.util.*;

/**
 * Prompts and gets input from the user regarding
 * the midterm and final. 
 * 
 * @param	val		determines whether to print midterm or final
 * 
 * @return The weighted score of the exam
 */
public class Gradanator {

	//The scanner to be used for all user input
	private static Scanner sc;
	private static final int MAX_EXAM_POINTS = 100;
	private static final int MAX_SECTION_POINTS = 20;
	
	/**
	 * Simple functions which greets the user and
	 * describes the purpose/function of the program
	 * 
	 * @param None
	 * 
	 * @return None
	 */
	public static void greetUser(){
		
		System.out.println("This program reads exam/homework scores");
		System.out.println("and reports your overall course grade.\n");
		return;
	
	}
	
	/**
	 * Determines the weighted score of a particular grade based on
	 * the initial score/max and the weight of the assignment
	 * 
	 * @param	score	The amoun