![Problem Solving with C++ (9th Edition)](https://www.bartleby.com/isbn_cover_images/9780133591743/9780133591743_largeCoverImage.gif)
Concept explainers
My mother always took a little red counter to the grocery store. The counter was used to keep a tally of the amount of money she would have spent so far on that visit to the store, if she bought all the items in her basket. There was a four-digit display, increment buttons for each digit, and a reset button. There was an overflow indicator that came up red if more money was entered than the $99.99 it would register. (This was a long time ago.) Write and implement the member functions of a class Counter that simulates and slightly generalizes the behavior of this grocery store counter. The constructor should create a Counter object that can count up to the constructor’s argument. That is, Counter(9999) should provide a counter that can count up to 9999. A newly constructed counter displays a reading of 0. The member function void reset(); sets the counter’s number to 0. The member functions void incr1(); increments the units digit by 1, void incr10(); increments the tens digit by 1, and void incr100(); and void incr1000(); increment the next two digits, respectively. Accounting for any carry when you increment should require no further action than adding an appropriate number to the private data member. A member function bool overflow(); detects overflow. (Overflow is the result of incrementing the counter’s private data member beyond the maximum entered at counter construction.)
Use this class to provide a simulation of my mother’s little red clicker. Even though the display is an integer, in the simulation, the rightmost (lowerorder) two digits are always thought of as cents and tens of cents, the next digit is dollars, and the fourth digit is tens of dollars.
Provide keys for cents, dimes, dollars, and tens of dollars. Unfortunately, no choice of keys seems particularly mnemonic. One choice is to use the keys asdfo: a for cents, followed by a digit 1 to 9; s for dimes, followed by digits 1 to 9; d for dollars, followed by a digit 1 to 9; and f for tens of dollars, again followed by a digit 1 to 9. Each entry (one of asdf followed by 1 to 9) is followed by pressing the Return key. Any overflow is reported after each operation. Overflow can be requested by pressing the o key.
![Check Mark](/static/check-mark.png)
Want to see the full answer?
Check out a sample textbook solution![Blurred answer](/static/blurred-answer.jpg)
Chapter 10 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Introduction To Programming Using Visual Basic (11th Edition)
Artificial Intelligence: A Modern Approach
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Absolute Java (6th Edition)
Modern Database Management (12th Edition)
C++ How to Program (10th Edition)
- C# program thankyou A minivan has two sliding doors. Each door can be opened by either adashboard switch, its inside handle, or its outside handle. However, the inside handles donot work if a child lock switch is activated. In order for the sliding doors to open, the gear shiftmust be in park, and the master unlock switch must be activated. Your task is to simulate a portion of the control software for the vehicle. The input is a sequenceof values for the switches and the gear shift, in the following order:• Dashboard switches for left and right sliding door, child lock, and master unlock (0 for off or 1for activated)• Inside and outside handles on the left and right sliding doors (0 or 1)• The gear shift setting (one of P N D 1 2 3 R).A typical input would be 0 0 0 1 0 1 0 0 P.Print “left door opens” and/or “right door opens” as appropriate. If neither door opens, print “bothdoors stay closed”.arrow_forwardYou are participating in a competition related to security, each participant is given a bank card and is asked to secretly set a 4-digit pin number for that card. The cards are then exchanged between participants. Each participant is given a card reading machine, where you can input the pin and the machine will tell you if the pin was correct or not. Your task is to find the pin entered by the other participant. A) What Al method will you use to obtain the 4-digit pin number stored in the card? [] B) Write a program in python that simulates the entire competition where the secret 4-digit number is entered by the user as an input. Then, simulate the card reader functionality where if the correct 4-digit key is provided it results with true value and false otherwise. Finally write your program that attempts to find the inputted number by using the simulated card reader only. [] C) Generate 100 random pins by going to the website https://www.coolgenerator.com/pin-generator. Run your code…arrow_forwardJoe’s Ristoranté is a small restaurant near a college campus. It serves both lunch and dinner from a standard menu. It also has a salad bar. Staff take orders by writing down the orders on an order pad. The orders are then taken to the kitchen where the food is prepared. When the food is ready, the staff are notified and deliver the food to the customer’s table. When the meal is finished, the staff provide customers with a bill, which has been prepared by hand. All sales must be paid by cash or credit card and entered into the cash register. Joe maintains one checking account for all sales receipts. Required: Create an REA diagram for Joe’s order-taking and cash receipts process, including all relationships.arrow_forward
- As you visit the La Filipina Ecopark together with your friend, you can't help but admire the nature around you including the many species of our native trees. Despite your interest, you are a very unskilled botanist and have a lot of trouble identifying different trees. Your botanist friend gives you partial guidance and you decide to write a program that will give you the name of the tree based on its characteristics. Your botanist told you that there are only 5 tree species in this eco-park, he gave you a list of 5 tree species: Tree Species Dao Katmon Yakal Kamagong Gisok-gisok Wood Density Tree size 0.500 to 0.600 0.601 to 0.700 0.701 and above 0.701 and above 0.701 and above L M L M S Assume that you can instantly measure the wood density and infer its tree size correctly. Your program should read the actual measurement of wood density (i.e. double) and your inferred tree size (i.e. char) and should be able to determine and display the name of the corresponding tree. If the wood…arrow_forwardThe cubic B-spline below has some repeated control points. Label each control point with the number of times it is repeated (that is, the number of the points at that same location). G C В Control point A 1 2 Control point A Control point B Control point C Control point D Control point E Control point F Control point Garrow_forwardSkydiving Bibi is a skydiving instructor. Before carrying out skydiving activities, Bibi will always ask the name, height, and age of the participants. Bibi's participants is always 2 people. To make it easier to remember their identities, Bibi gave them a paper to write down their identity. But because they are very enthusiastic in doing skydiving, they write their identity in a single line only (for both of the participants), so it wasn't quite neat and it made difficult for Bibi to see it, and resulted in the skydiving process being disturbed. As one of the organizer committee, you do not want this activity to be disturbed and plan to provide a program that provides their identity neatly to Bibi. Format Input Input consists of 1 line. It contains the identity of 2 people in a row Ni, Ti, Ui - the name, height, and age of the i-th participant. Format Output The output consists of 6 lines. The first line, "Name 1: N1". The second line, "Height 1: T1". The third line, "Age: U1". For…arrow_forward
- Scenario Instructions You are a Mathematics major who has agreed to teach an elementary school math class where the students are studying geometry. They are just starting to learn about sine, cosine, and tangent. You've decided that you want to show the students what these functions look like when they have been graphed. Write a Python program to display three separate graphs for sin, cos, and tan. Add the ability to show all three graphs on a single graph with one row and three columns.arrow_forwardProgramming language: Python.arrow_forwardWhich scenarios would cause an error ?arrow_forward
- Programming Language: PHP Using any Iteration Control Structure, create a program that will ask the user to input one integer, then display a simple multiplication table of the said integer.Example: Inputed integer: 1010 x 1 = 1010 x 2 = 20...10 x 10 = 100arrow_forwardmodify it based on the instructions below: -clicking a to add the amount (which shouldn't be displayed before pressing a, it should just have the info), -clicking b which will modify only the last name to uppercase (the first and last name are already uppercase before I press b which shouldn't be happening, and 'b' is used for another feature not just changing it to uppercase) maybe use an if statement and ask the user if they want to change it to uppercase for the first or last name, or -increase the hourly rate by 10 for comp sci majors. -clicking b should also add 10 to the hourly rate for computer science majors when updating data so if you could implement that please -the last thing is when clicking c, you should be able to insert a new node to the sequence with the amount calculated and display it, make it so the user can enter In the new node and have it displayed. please do it in a timely manner code below #include <bits/stdc++.h>using namespace std; struct…arrow_forward1. CPU- • Math commands like "Add 5 to x" or "Subtract 3 from y" should be sent to the ALU. • Drawing commands like "Plot(x,y)" should be sent to the Display. First, ask the Memory for the current values of x and y, then give them to the Display. Be sure to check off each line of the program as you finish it (so that you don't lose track of where you are). Add 4 to x Add 2 toy Plot (x, y) Add 1 to x Add 4 to y Plot (x, y) Add 3 to x Add 2 to y O Plot (x, y) O Subtract 6 from x Plot (x,y) Subtract 3 from x Add 1 to y Plot (x,y) Subtract 5 from y Plot (x, y) Add 4 to x Add 2 to y Plot (x, y) Add 5 to x Subtract 3 from y Plot (x,y) O Subtract 1 from x O Add 5 to y Plot (x, y) Subtract 6 from x Plot (x, y) Add 3 to x Subtract 3 from x Add 4 to y Subtract 1 from y O Plot (x,y) O subtract 4 from y O Plot (x, y) Plot (x, y) Add 3 to x Subtract 5 from y Plot (x, y) Subtract 1 from x DONE ! Add 1 to y Plot (x, y) Add 4 to x O Subtract 1 from y O Plot (x,y)arrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageNew Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage Learning
![Text book image](https://www.bartleby.com/isbn_cover_images/9781305503922/9781305503922_smallCoverImage.gif)