Concept explainers
Driver’s License Exam
The local Driver’s License Office has asked you to write a
- 1. B
- 2. D
- 3. A
- 4. A
- 5. C
- 6. A
- 7. B
- 8. A
- 9. C
- 10. D
- 11. B
- 12. C
- 13. D
- 14. A
- 15. D
- 16. C
- 17. C
- 18. B
- 19. D
- 20. A
A student must correctly answer 15 of the 20 questions to pass the exam.
Write a class named DriverExam that holds the correct answers to the exam in an array field. The class should also have an array field that holds the student’s answers. The class should have the following methods:
- passed. Returns true if the student passed the exam, or false if the student failed
- totalCorrect. Returns the total number of correctly answered questions
- totalIncorrect. Returns the total number of incorrectly answered questions
- questionsMissed. An int array containing the question numbers of the questions that the student missed
Demonstrate the class in a complete program that asks the user to enter a student’s answers, and then displays the results returned from the DriverExam class’s methods.
Input Validation: Only accept the letters A, B, C, or D as answers.
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Starting Out with Java: Early Objects (6th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (3rd Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Computer Science: An Overview (12th Edition)
Starting Out With Visual Basic (8th Edition)
- Odd Even Number Problem Description Even Numbers are integers that are exactly divisible by 2, whereas an odd number cannot be exactly divided by 2. Example of even numbers are 2,4,6,8 and odd numbers are 1, 3, 5, 7, 9. Input The first line input contains an integer, which determines the number of test cases. Each of following lines represent sequence of integers that ends with 0. 2 34 1 8 5 22 0 10 7 16 -2 0 Output For each test case, the output will present the size of oddQueue and evenQueue following with the integers of odd and even numbers. oddQueue 2: 1 5 evenQueue 3: 34 8 22 oddQueue 1: 7 evenQueue 3: 10 16 -2 ** Your task is to write a program that will read the input and identify whether it is an odd number or even number. /******************************************************************************* Compilation: javac Queue.java** The Queue class represents a first-in-first-out (FIFO) queue of generic items.* It supports the usual enqueue and dequeue…arrow_forwardAn online book club awards points to its customers based on the number of bookspurchased each month . Points are awarded as follows:Books Purchased01234 or morePoints Earned051530soWrite a program that asks the user to enter the number of books purchased this monthand then displays the number of points awarded .arrow_forwardTime CalculatorWrite a program that asks the user to enter a number of seconds.-There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes and leftover seconds in that many seconds.-There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours, minutes, and leftover seconds in that many seconds.-There are 86,400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86,400, the program should display the number of days, hours, minutes, and leftover seconds in that many seconds.arrow_forward
- Percentage of vehicles: Write an interactive program that asks the users to input the number of cars, trucks and suv that entered a parking lot. Your progam should then calculate the percetages of each vehicle type and display the result.arrow_forwardValidy options is: Valid / Invalidarrow_forwardComputer Science PYTHON PROGRAMMING Write a program that generates a random number in the range of 1 through 100, and asks the user to guess what the number is. If the user's guess is higher than the randomly generated number, the program should display "Too high, try again." If the user's guess is lower, the program prints "Too low, try again." If the user guesses the number, the application should congratulate the user and generate a new random number so the game can start over. Keep track of the number of guesses a user makes before guessing the correct one and display it with the congratulatory message when the user guesses the number correctly. For this assignment, create functions that: generate and return a random number between 1 and 100. format and return the failure and congratulatory messages. Put these function in a module called helper.py and put the rest of the code in game.py. The game module must import the helper module. Please provide both helper.py & game.py…arrow_forward
- Widgets and Gizmos An online retailer sells two products: widgets and gizmos. Each widget weighs 75 grams. Each gizmo weighs 112 grams. Write a program that reads the number of widgets and the number of gizmos in an order from the user. Then your program should compute and display the total weight of the order.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_forwardRandom Number Guessing Game Create an application that generates a random number in the range of 1 through 100 and asks the user to guess what the number is. If the user’s guess is higher than the random number, the program should display “Too high, try again.” If the user’s guess is lower than the random number, the program should display “Too low, try again.” If the user guesses the number, the application should congratulate the user and then generate a new random number so the game can start over. Optional Enhancement: Enhance the game so it keeps count of the number of guesses that the user makes. When the user correctly guesses the random number, the program should display the number of guesses.arrow_forward
- Web page bill calculator. User inputs the "item name" and "item amount" on the webpage. The webpage will return the total money he need to pay. If the payment is more than 30 dollars, the user can have a 10% off discount. Bill = (item cost )* (# of items) Item cost apple orange peach $1.2 $2arrow_forwardMicrowaves / Radio Waves If a scientist knows the wavelength of an electromagnetic wave she can determine what type of radiation it is. Write a program that asks for the wavelength in meters of an electromagnetic wave and then displays what that wave is according to the following chart. (For example, a wave with a wavelength of 1E-10 meters would be an X-ray.) 1x 10-11 1 x 10-8 4 x 10-7 7x 10-7 1x 10-3 1 x 10-2 Gamma Rays. X Rays Ultraviolet Visible Light Infraredarrow_forwardSports exercise advisor algorithm. In this algorithm you will start out with a temperature value in Celsius, so you do not need to ask the user for it. First, convert the temperature to Fahrenheit. Then display a recommended sports exercise based on the Fahrenheit temperature as follows: for temperatures between 65 and 80° display tennis, for colder temperatures display ping pong, and for warmer temperatures display canoeing. thanks in advancearrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,