Create a class that represents a grade distribution for a given course. Write methods to perform the following tasks:
- Set the number of each of the letter grades A, B, C, D, and F.
- Read 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 five 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 Bs, 6 Cs, 2 Ds, and 1 F, the total number of grades is 14, the percentage of As is 7, the percentage of Bs is 29, the percentage of Cs is 43, the percentage of Ds is 14, and the percentage of Fs is 7. The A row would contain 4 asterisks (7 percent of 50 rounded to the nearest integer), the Brow 14, the C row 21, the D row 7, and the F row 4. The graph would look like this:
Trending nowThis is a popular solution!
Chapter 5 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (8th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Starting Out with C++: Early Objects
C Programming Language
Starting Out with Python (3rd Edition)
- An alternative approach to creating your methods is to use heredocs.arrow_forwardcanMove(int x, int y, int destX, int destY, Side s): This method returns true if the player of color s can move the piece at coordinates (x,y) can move to coordinates (destX, destY) on the board in its current state. This means that here you do need to consider this piece’s interaction with other pieces on the board. Conditions for this method to return false are given in the code. public boolean canMove(int x, int y, int destX, int destY, Side s){ /* TODO write a method that checks if a piece at coordinates x,y can move to coordinates destX,destY Conditions for false: - Origin or destination coordinates are outside the board - Piece at origin is null - If source and destination coordinates are the same - Piece at origin is not of the same side as s - You can check this using piece.getSide() - Piece cannot move to the destination by piece movement rules - You should check this using Piece.canMove(destX,…arrow_forwardCreate a Golf Game. Allow for two players. Prompt for the player names. Each player plays 18 holes. Use an array or List for each player to hold their number of swings for each hole. Logical methods should be implemented for different tasks (broken out below). It is up to you to determine the parameters and return types of each method as appropriate. Method 1 - For each hole, the player has a number of swings. Determine the player's swings by generating a random number between 1 and 4. Store each players number of swings in the array/list. Method 2 - After completing the 18 holes, add up the number of swings for each hole for each player. The player with the fewest number of swings is the winner. Method 3 - Save the game data into a CSV file in the main project (root) directory. Name the file "Golf_Game_Player1_Player2.csv" using the player's names. The information in the file should look like this: playername, scoreforhole1, scoreforhole2, scoreforhole3, etc... Method 4 - In the…arrow_forward
- Screen shot pleasearrow_forwardQ2: Wire a code for an Arduino Car Speed Detector shown in the schematic diagram below (IR sensor=KY-032) IR sensor 1 IR sensor 2 How it works: This project works on a simple physics law of calculating the speed as distance/time. Speed = Distance/Time When a car passes the ist IR sensor, it detects and save the first-time value. Then we measure the second time value when the car reaches the IR sensor 2. The difference of both the time is the travel distance from one sensor to the other. We get the time in which car travels a distance of 10 meters so we can calculate the speed of the car. 10 metersarrow_forwardAssignment using Methods For this exercise, you need to complete all the questions in a single project. You will invoke the methods from your main. Questions 1-6 is due at the end of your next class. Write a method with the following specifications:name: DisplayMenuarguments: nonereturn value: nonetasks: display the following menu choice on the screenCalculation Menu3) Calculate Sum 4) Calculate Sum of Squares5) Calculate Sum of Cubes0) To ExitEnter the number that corresponds to your choice: You may beautify the output to your own likings. You don’t have to implement the functionalities of the various menu choices at this stageCall this method from your main. Modify your main so that the above method is call repeatedly. The program will terminate when the user enters 0. Any other choice should produce an error message. Because you will not be doing any arithmetic you may accept the user response either as an int, or a char or a string. Write a method with the following…arrow_forward
- For this project, you will create a class for an elementary school that will allow a teacher to enter each student's seating assignment. Occasionally, the teacher may need to switch the seating assignment of a student. If there is a seat available, the student is moved. If all of the seats are already assigned, the teacher will have two students trade seats. Minimum Requirements: • Create a class called student that holds information about one student including the student's name. The class must have methods to set each instance variable and methods to get each instance variable. • Create a class called seatingChart and create a multidimensional array of student objects as an instance member. The array of student objects should be able to handle a class of size 20. You will not get credit for this assignment if you do not use a multidimensional array for the seating chart. • Include an addStudent function that has parameters for a student name, target seat row and column to add one…arrow_forwardmaximum hours (inclusive). Make sure to cast the maximum range to an int before using it as parameter invoke the method to start the engine invoke the fly method and use as the input parameter the random number generated on the previous step invoke the method to land the plane and stop the engine invoke the addGas method. Invoke the calcGasNeededToFillTank () method to figure out the fuel needed to fill the tank and pass this value as input parameter to the addGas method.arrow_forwardIN JAVA LANGUAGE Write an ATM class with an ArrayList of Account objects as an attribute. In the constructor, add 3 Account objects to your ArrayList. They can all have a start balance of $100 and an annual interest rate of 0.12. Include two methods, menu and makeSelection as outlined below. Please note that since both methods get user input, create a Scanner attribute to use in both. menu method This method does not have any parameters and does not return a value. It should: Get the account number from the user. This corresponds to the index of the items in the ArrayList. Since there are 3 elements in your ArrayList, you are going to ask them for a number between 1 and 3, but keep in mind that the indices of the ArrayList are 0-2, so you'll have to adjust the value you get from the user accordingly. Present the user with a main menu as shown below: Get their menu selection Call the makeSelection method, passing it the account index obtained in step 1 and the menu selection…arrow_forward
- 15-5. Refactoring: The fill_walk() method is lengthy. Create a new method called get_step() to determine the direction and distance for each step, and then calculate the step. You should end up with two calls to get_step() in fill_walk(): x_step = self.get_step()y_step = self.get_step() This refactoring should reduce the size of fill_walk() and make the method easier to read and understand. Do this in the RandomWalk1 class. No need to turn in a program called 15-5, just have the refactored code in your random_walk.py file. 15-6. Two D8s: Create a simulation showing what happens when you roll two eight-sided dice 1000 times. Try to picture what you think the visualization will look like before you run the simulation; then see if your intuition was correct. Gradually increase the number of rolls until you start to see the limits of your system’s capabilities. Adjust comments, labels and file names for the new program. Start with die_visual_4.py.arrow_forwardHi I like this code but is it possible to incorportate the 3 methods, because i dont see it in the current code - void yourTurn ( ) - This method handles moves made by the user. It displays the game board and asks the user to enter a move. If the move is invalid, it prompts user to enter a valid move again. A valid move refers to one of the empty cells in the board. void machineTurn ( ) - This method handles moves by the computer. One possibility is to search for an empty position in the array and mark it for the computer player main ( ) - The main method controls the game. You will declare an array for the game and make use of the methods that you have written to produce behavior of the Tic-Tac-Toe game. The human player always makes the first move in the game. You should alternate between the human player and the computer. After each move you should check for a winner using the checkWinner method. While there is no winner, you should display the gameboard, ask the user for next…arrow_forwardThe weather generator methods you will be writing for this assignment will: predict future precipitation pattern for one month: oneMonthGenerator find the number of wet or dry days in a given month’s forecast: numberOfWetDryDays find the longest wet or dry spell in a given month’s forecast: lengthOfLongestWetDrySpellarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education