Solution to
To combat election fraud, your city is instituting a new voting procedure. The ballot has a letter associated with every selection a voter may make. A sample ballot is shown.
1. VOTE FOR MAYOR
A.
Pincher, Penny ▢ |
B.
Dover, Skip ▢ |
C.
Perman, Sue ▢ |
2. PROPOSITION 17
D.
YES ▢ |
E.
NO ▢ |
3. MEASURE 1
F.
YES ▢ |
G.
NO ▢ |
4. MEASURE 2
H.
YES ▢ |
I.
NO ▢ |
After submitting the ballot, every voter receives a receipt that has a unique ID number and a record of the voting selections. For example, a voter who submits a ballot for Sue Perman, Yes on Proposition 17, No on Measure 1, and Yes on Measure 2 might receive a receipt with
ID 4925 : CDGH |
The next day the city posts all votes on its Web page sorted by ID number. This allows a voter to confirm their submission and allows anyone to count the vote totals for themselves. A sample list for the sample ballot is shown.
4925 | CDGH |
4926 | AEGH |
4927 | CDGI |
4928 | BEGI |
4929 | ADFH |
Write a program that reads the posted voting list from a file and outputs the percent of votes cast for each ballot item. You may assume that the file does not have any header lines. The first line will contain a voter ID and a string representing votes. Define a class named Voter that stores an individual’s voting record. The class should have a constructor that takes as input a string of votes (for example, “CDGH”), a voter ID, and accessor function(s) that return the person’s ID and vote for a specific question. Store each Voter instance in an array or
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (8th Edition)
Software Engineering (10th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Starting Out with C++: Early Objects (9th Edition)
- 1. In the game of Monopoly, a pair of dice are rolled to move a player's piece around the board. If a double is rolled (the dice show the same number), the player receives another roll of the dice. If a double is rolled a second time, a third roll of the dice is received. If a double is rolled on the third occasion, the player forfeits their turn (and goes to Jail). Write a program which simulates two players having 50 turns each (a turn however many dice rolls a player has in a row before it's the other player's turn) and determines: a) the total number of spaces moved by each player; and b) how many times a player rolls a double which results in movement of a piece. Use the randi function. For fun, incorporate the rule that a player cannot leave Jail (cannot move) unless they either roll a double or three turns have passed without rolling a double.arrow_forwardWhat is the given prompt asking, to be programmed in Java?arrow_forwardUOWD Library is asking you to write a Java program that manages all the items in the Library. The library has books, journals, and media (DVD for example). All items have a name, author(s), and year of publication. A journal also has a volume number, while a media has a type (audio/video/interactive). The user of your program should be able to add an item, delete an item, change information of an item, list all items in a specific category (book, journal, or media), and print all items (from all categories). A menu asks the user which operation s/he wants to perform. Important: make use of collections, inheritance, interfaces, and exception handling wherever appropriate.arrow_forward
- This needs to be done in Java! (Sales Commission Calculator) A large company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5,000 worth of merchandise in a week receives $200 plus 9% of $5,000, or a total of $650. You’ve been supplied with a list of the items sold by each salesperson. The values of these items are shown below. Develop a Java application that inputs one salesperson’s items sold for last week and calculates and displays that salesperson’s earnings. There’s no limit to the number of items that can be sold. Item Value 1 239.99 2 129.75 3 99.95 4 350.89 Example Output: Enter number sold of product #1: 10Enter number sold of product #2: 20Enter number sold of product #3: 30Enter number sold of product #4: 40Earnings this week: $2182.61 NOTES: Do not create a separate class for this program. Create the…arrow_forwardUse Java.arrow_forwardStarting Out with Java From Control Structures through Objects 6th Edition 4. Paint Job Estimator A painting company has determined that for every 115 square feet of wall space, one gallonof paint and eight hours of labor will be required. The company charges $18.00 per hourfor labor. Write a program that allows the user to enter the number of rooms to be paintedand the price of the paint per gallon. It should also ask for the square feet of wall space ineach room. The program should have methods that return the following data: • The number of gallons of paint required• The hours of labor required• The cost of the paint• The labor charges• The total cost of the paint jobThen it should display the data on the screen.arrow_forward
- C++ The restaurant owner wants to give those attending a specific dish, but the method yields a lot more food than what he can give. Because of this, the kitchen staff is interested in creating a meal with fewer ingredients but with identical ingredient ratios. Yet, the cook dislikes fractions. The cook desires that the decreased method also include just whole numbers of items since the earlier method only called for entire numbers. Assist the cook in deciding the quantity of each ingredient to use to produce the least amount of food. Input 3 244 3234 43 1596 Output 11 234 1532arrow_forwardHow can I express the following situation in Java programming? Orcs, Hobbits, and Tom Bombadil We have n-1 Orcs and n Hobbits who want to cross a river. We also have Tom Bombadil who wants to cross as well. Only Hobbits and Tom Bombadil can row the boat (don’t ask me why!) At all times, the number of Hobbits on either side of the river must be greater or equal the number of Orcs on that side (unless there are no Hobbits on that side), or the Hobbits will be killed by the Orcs! If the boat holds 2, with n=4 or more, the problem has no solution. If the boat can hold 3, then up to n=5 can be solved. If the boat can hold 4, any number (n) Hobbits can cross. So -- if n = 1,2 or 3 - use a boat of size 2. If n = 4 or 5 - use a boat of size 3. If n > 5 use a boat of size 4. If n <0 invalid input if n = 0 no output.arrow_forward.arrow_forward
- Need to handle in javaarrow_forwardC++ Code Mr. Naughty loves to play with balls. So, his friend, Mr. Nice, gave him n balls to play the game. Each ball has exactly two numbers (more number and number below). In one move Mr. Naughty can rotate any ball that its bottom is now rising. Mr. Nice knows a small amount of this movements that can make at least half of the balls show the same number at the top. So, in order to win Mr Nice's game, Mr. Naughty has to earn a small amount of it it goes. It is not always possible to make such movements that satisfy what is provided in this case Mr. Naughty should see that it is "Impossible" to make such movements. Help Mr. Naughty win the game. Input 3 3 100 100 3 54 Output 5arrow_forwardWrite a program to build a calculator. Instead of a typical calculator which reads in-order expressions and evaluates them, build a calculator that takes in numbers and assigns the operations to yield the highest value expression. The current operations on the calculator only handle pairs of parentheses, and the operators for addition, subtraction, multiplication, and division. The calculator can rearrange the numbers if it helps find the optimal value. For example, the list:4.0 5.0 3.0 2.0 1.0using the calculator should find the optimal expression yielding the maximum value to be:4.0 * 5.0 * 3.0 * (2.0 + 1.0) = 180Input from the keyboard a list of up to 10 floating-point values from-100000.0to100000.0. Output to the screen a single floating-point value rounded to two decimal places representing the highest value expression that the calculator could create by inserting the symbols( ) + - * /into the given expression. Assume at least one number in the list and only the operators listed…arrow_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