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.
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Problem Solving with C++ (10th 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)
- what's the error?arrow_forwardI've been given this problem and I need to use a loop to create these patterns. I remember using a while loop and im not very familiar with a for loop. the programming language here is java. i'm more familiar with python and even with that language i struggled to do this. how do i use a loop to create these patterns? was the while loop the wrong idea and maybe i should've for looped it? here are the instructions i was given, i cant seem to create the pattern Printing a single character at a time create loops to Print the following patterns: Pattern 1:********** Pattern 2 * *** ***** *** * Pattern 31010101 10101 101 1arrow_forwardThe Ibra College of Technology has an automated system that calculates the overall grade for each student of a class. The system gets to know the number of students in a class from the teacher. For each student, it asks their name and the number of subjects they took. For each subject, they ask the score. They then take the average of the scores of all the subjects, divide it by 10 and display the name and GPA for each student. Read the number of students in a class, the name and the number of subjects for each student. Then read the scores of each subject for each student, calculate the GPA by averaging the scores and dividing the average by 10. Finally, display the name and GPA for each student.arrow_forward
- Instructions Objectives: Use a while loop Use multiple loop controlling conditions Use a boolean method Use the increment operator Extra credit: Reuse earlier code and call two methods from main Details:This assignment will be completed using the Eclipse IDE. Cut and paste your code from Eclipse into the Assignment text window. This is another password program. In this case, your code is simply going to ask for a username and password, and then check the input against four users. The program will give the user three tries to input the correct username-password combination. There will be four acceptable user-password combinations: alpha - alpha1 beta - beta1 gamma - gamma1 delta - delta1 If the user types in one of the correct username-password combinations, then the program will output: “Login successful.” Here are a couple of example runs (but your code needs to work for all four user-password combinations): Username: betaType your current password: beta1Login…arrow_forwardIn visual basic, or Visual Studio Create the following output using nested For…Next loops: 1 6 11 16 2 7 12 17 3 8 13 18 4 9 14 19 5 10 15 20 Write a nested For…Next loop to create the following pattern: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5arrow_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_forwardScenario 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_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
- Create a flow chart. The last guy who answered this only debugged it. He didn't make a flow chartarrow_forwardFill in the blank When the markdown is added to the selling price, you may determine the price of an item.arrow_forwardIn a team of up to three people, develop an algorithm and illustrate a flowchart which displays a Level Selection Screen which is dynamically generated 区 Level images and star ratings are stored in an array, which you can iterate through to extract and display on screenarrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageNew Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage Learning