## Description

Abstract

Your task is to complete three problems from the textbook. These problems are easier than they appear at the rst glance if you remember to focus on each individual method you need to write as its own

problem.

You should not have to use Scanner except to test the class.

Create a Class that represents a grade distribution for a given course. Write methods to perform each of the following tasks:

Set the number of each of the letter grades A, B, C, D and F.

Return the number of each of the letter grades A, B, C, D and F.

Return the total number of grades.

Return the percentage of each letter grade as a whole number between

0 and 100, inclusive.

Draw a bar graph of the grade distribution.

The graph will have ve bars, one per grade. Each bar can be a horizontal row of asterisks, such that the number of asterisks in a row is proportionate to the percentage of grades in each category. Let one asterisk represent 2

percent, so 50 asterisks correspond to 100 percent. Mark the horizontal axis at 10 percent increments from 0 to 100 percent, and label each line with its letter grade.

For example, if the grades are 1 A, 4 B’s, 6 C’s, 2 D’s and 1 F, the total number of grades is 14, the percentage of A’s is 7, the percentage of B’s is 29, the percentage of C’s is 43, the percentage of D’s is 14, and the percentage of F’s is 7. The A row would contain 4 asterisks (7 percent of 50 rounded o to the nearest integer), the B row 14, the C row 21, the D row 7 and the F row 4. The graph would look like this:

0 10 20 30 40 50 60 70 80 90 100%

| | | | | | | | | | |

***************************************************

**** A

************** B

********************* C

******* D

**** F

1.1 First steps

Think about what instance variables you need for these methods.

2 Assignment 2

Consider a class that could be used to play a game of hangman. The class has the following attributes:

The secret word

The disguised word, in which each unknown letter in the secret word has been replaced with a question mark (?). For example, if the secret word is abracadabra and the letters a, b and e have been guessed, the disguised word would be ab?a?a?a?ab?a.

The number of guesses made.

The number of incorrect guesses.

The class would have the following methods:

makeGuess(char c) guesses that character c is in the word.

getDisguisedWord() returns a String containing correctly guessed let-

ters in the correct positions and unknown letters replaced with ?.

getSecretWord() returns the secret word.

getGuessCount() returns the number of guesses made.

isFound() returns true if the hidden word has been discovered.

Your task is to implement the class with the above variables and methods, then implement a \game” of hangman using this class. Your program doesn’t need to draw anything.

Assignment 3

Consider a class Movie that contains information about a movie. The class has the following attributes:

The movie name

The MPAA rating (G, PG, etc)

The number of 1-star reviews

The number of 2-star reviews

The number of 3-star reviews

The number of 4-star reviews

The number of 5-star reviews

Implement this class and create the following methods:

An accessor and mutator (also called getters and setters, respectively) for the movie name.

An accessor and mutator (also called getters and setters, respectively) for the MPAA rating.

addReview(int stars) that takes in an integer as an input parameter. The method should verify if the parameter is between 1 and 5, and if so, increment the number of reviews with that many stars by one.

Write another method, getAverage(), which returns then average value for all the reviews.

Test the class by writing a main method that creates at least two movie objects, adds at least ve ratings for each movie, and outputs the movie name, the MPAA rating, and the average rating fo each movie object.