Concept explainers
Driver’s License Exam
The State Department of Motor Vehicles (DMV) has asked you to write a
1. B | 5. C | 9. C | 13. D | 17. C |
2. D | 6. A | 10. D | 14. A | 18. B |
3. A | 7. B | 11. B | 15. D | 19. D |
4. A | 8. A | 12. C | 16. C | 20. A |
To do this, you should create a TestGrader class. The class will have an answers array of 20 characters, which holds the correct test answers. It will have two public member functions that enable user programs to interact with the class: setKey and grade. The setKey function receives a 20-character string holding the correct answers and copies this information into its answers array. The grade function receives a 20-characte r array holding the test taker’s answers and compares each of their answers to the correct one. An applicant must correctly answer 15 or more of the 20 questions to pass the exam. After “grading” the exam, the grade function should create and return to the user a string that includes the following information:
• A message indicating whether the applicant passed or failed the exam
• The number of right answers and the number of wrong answers
• A list of the question numbers for all incorrectly answered questions
The client program that creates and uses a TestGrader object should first make a single call to setKey, passing it a string containing the 20 correct answers. Once this is done, it should allow a test taker's 20 answers to be entered, making sure only answers of A-D are accepted, and store them in a 20-character array. Then it should call the grade function to grade the exam and should display the string the function returns. The program should loop to allow additional tests to be entered and graded until the user indicates a desire to quit.
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
STARTING OUT WITH C++ MPL
Additional Engineering Textbook Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out with Java: Early Objects (6th Edition)
Problem Solving with C++ (9th Edition)
Concepts Of Programming Languages
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Digital Fundamentals (11th Edition)
- Software Sales A software company sells a package that retails for $99. Quantity discounts are given below: Quantity Discount 10–19 20% 20–49 30% 50–99 40% 100 or more 50% Design a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount.arrow_forwardHide Assignment Information Instructions The civil engineering department has asked you to write a program to compare three different designs of water towers shown in the diagrams below. The water towers are a cylinder topped with a half sphere. The engineers want to find the design that has the highest volume. The radius of the sphere and the radius and height of the cylinder for each of the three projects will need to be input by the user. The formula for the volume of a Sphere is:V = 4/3 π r3The formula for the volume of a Cylinder is:V = π r2 h Write two functions that will calculate the volume of a sphere and a cylinder respectively. Then, use these functions to write a program that will find the design with the largest volume. Hint: Remember that the tower only consists of a half sphere.arrow_forwardPython programming language You will be creating an application to calculate the maximum amount of contribution a person can make to a Roth IRA based on their age and income. Over 50 years old and your contribution limit goes up from $6000 to $7000 dollars. However, if the person is married and the combined household income is over $206,000 a year, or a single person with income over $139,000, you are not allowed to contribute. Write an application that asks the user their age and their income. Using this information use a nested if statement to calculate the maximum allowable contribution.arrow_forward
- Serendipity Booksellers has a book club that awards points to its customers based on the number of books purchased every month, The points are awarded as follows 1.If a customer purchases 0 books, he or she earns points 0 If a customer purchases 1 books, he or she earns points 5 If a customer purchases 2 books, he or she earns 15 points If a customer purchases 3 books, he or she earns 30 points If a customer purchases 4 or more books he or she earns 60 points Design a program using pseudocode that asks the user to enter the number of books that he or she has purchased this month and displays the number of points awarded . Here are some necessary parameters to follow to help solve the problem. Please write line numbers before each line of the algorithm, include blank numbered lines between modules and write comments 1.Create a main module. It should declare one local variable and call two other modules 2. Create a module to get input from the software user 3.Create a module to…arrow_forwardGreenLawn a local lawn care company has different pricing policies for its customers. GreenLawn sends out monthly invoices and will give discounts if payments are made within 5 days. The discounting policy is as follow: If the amount of the monthly bill is greater than $300, subtract 4 percent from the invoice; if the amount is between $300 and $100, subtract a 2-percent discount; if the amount is less than $100, do not apply any discount. All bills made via the web automatically receive an extra 3-percent discount. Develop a decision for GreenLawn discounting decisions. Decision Table submission: Include the initial table with all rules, and the most simplified table. Use different colors in the columns to easily show how columns are collapsed/simplified. please do not provideo solution in image format thank you!arrow_forwardAn online book club awards points to its customers based on the number of books purchased each month. Points are awarded as follows: Books Purchased Points Earned 1 5 2 15 3 30 4 or more 60 Write a program that asks the user to enter the number of books purchased this month and then displays the number of points awarded.arrow_forward
- Validy options is: Valid / Invalidarrow_forwardPrice Calculator in Python Write a complete Python program that asks for the price of an item and the quantity purchased, and writes out the total cost.arrow_forwardFat Percentage Calculator One gram of fat has 9 calories. If you know the number of fat grams in a particular food, you can use the following formula to calculate the number of calories that come from fat in that food: Calories from fat = Fat grams × 9 If you know the food’s total calories, you can use the following formula to calculate the percentage of calories from fat: Percentage of calories from fat = Calories from fat ÷ Total calories Create an application that allows the user to enter: • The total number of calories for a food item • The number of fat grams in that food item The application should calculate and display: • The number of calories from fat • The percentage of calories that come from fat Also, the application’s form should have a CheckBox that the user can check if he or she wants to know whether the food is considered low fat. (If the calories from fat are less than 30% of the total calories of the food, the food is considered low fat.) Use the following test data…arrow_forward
- A software company sells a package that retails for $99. Quantity discounts are given according to the following table: Qt: 10 -19 Discount: 10% Qt: 20 -49 Discount: 20% Qt: 50 -99 Discount: 30% Qt: 100 or More Discount: 40% Write a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount. Python programming questionarrow_forwardInstructions The program in the Programming Example: Fibonacci Number does not check: Whether the first number entered by the user is less than or equal to the second number and whether both the numbers are nonnegative. Whether the user entered a valid value for the position of the desired number in the Fibonacci sequence. Rewrite that program so that it checks for these things. NOTES: If an invalid number is entered for case 1 above, prompt the user to enter both numbers again. If an invalid number is entered for case 2, prompt the user to enter a value until a valid value is entered. the code: #include <iostream> using namespace std; int main() { //Declare variables int previous1; int previous2; int current; int counter; int nthFibonacci; cout << "Enter the first two Fibonacci numbers: "; //Step 1 cin >> previous1 >> previous2; //Step 2 cout << endl; //verify the first two values if(previous1<0 && previous2>0)…arrow_forward44% 2:34 PM Theme Park Ticket Application In holidays, people try to save their time and purchase entrance tickets of the favored theme parks online. This project aims to create a simple and most efficient application that will display a menu to the visitors which contains: 1. Book a ticket The program will display a menu that contains all the ticket prices below, get how many tickets he/she would like to buy, and displays the total price. The ticket Price Child - Under 8 years old 70 USD Adults 110 USD Seiners 50 USD 2. Calculate the price The program should calculate the total price of tickets and display it to the visitor. The program will ask if the visitor is a student, then a discount of 40% is applied to the total price. 3. Exit the application The application should be terminatedarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT