Write a program that uses an int pointer called hand to manipulate 3 variables: book, pencil,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that uses an int pointer called hand to manipulate 3 variables: book, pencil, paper. You will use the hand pointer to change the value of book, pencil, or paper based on USER INPUT. The value stored in each variable represents a location: //GLOBAL VARIABLES const int FLOOR = 1, CHAIR = 2, DESK = 3; For example, if hand is pointing to pencil, you could change the location of pencil using: *hand = FLOOR; Use the following functions: //ask the user which object to grab, then return a pointer to that object int* grab(int &book, int &pencil, int &paper); //ask the user where they would like to move the object void move(int* hand); //show the location of each object & contents of hand void showAll(int* hand, int &book, int &pencil, int &paper); //helper function for showAll, outputs the location of a single object. string show(int object); The whole program should loop and give the user the following options: 1) Show All 2) Grab Object 3) Move Object 4) Exit Program Write a program that uses an int pointer called hand to manipulate 3 variables: book, pencil, paper. You will use the hand pointer to change the value of book, pencil, or paper based on USER INPUT. The value stored in each variable represents a location: //GLOBAL VARIABLES const int FLOOR = 1, CHAIR = 2, DESK = 3; For example, if hand is pointing to pencil, you could change the location of pencil using: *hand = FLOOR; Use the following functions: //ask the user which object to grab, then return a pointer to that object int* grab(int &book, int &pencil, int &paper); //ask the user where they would like to move the object void move(int* hand); //show the location of each object & contents of hand void showAll(int* hand, int &book, int &pencil, int &paper); //helper function for showAll, outputs the location of a single object. string show(int object); The whole program should loop and give the user the following options: 1) Show All 2) Grab Object 3) Move Object 4) Exit Program
Expert Answer:
Related Book For
Posted Date:
Students also viewed these algorithms questions
-
A bond portfolio has effective duration 5and convexity -23.The current market value of the portfolio is $100Billion.Use Taylor approximation and Duration and Convexity to find what would be the...
-
Consider the class definitions of Programming Exercise 5 in Chapter 14,Reusing Code in C++. If you havent yet done that exercise, do so now.Then do the following: Write a program that uses standard...
-
A sample containing an alkali sulfate is dried, weighed and dissolved in dilute HCl. Barium chloride solution is added in excess to precipitate barium sulfate, and the precipitate is digested in the...
-
Find the area under one arch of the cycloid x = a(t - sin t), y = a(1 - cos t).
-
Find the lowest temperature at which it is possible to have water in the liquid phase. At what pressure must the liquid exist?
-
A semi-annual coupon Corporate bond is quote das 85.94. This bond has 16 year sti maturity with a coupon rate of 5%. What is the current yield on this bond?
-
Dogway Candy Company sells candy on consignment to "big-box" stores and currently has $\$ 1,000,000$ in accounts receivable. Its days sales outstanding (DSO) is 50 days (based on a 365-day year). The...
-
How would you handle the issue if you were in Ricardo's position? Develop an action plan to get your point of view across. What would you say? What do you expect the objections or push-back will be?...
-
A sphere slides along a friction-free inclined surface n. The sphere slides from a height of n for the speed of the sphere once it reaches the point2. (b) 4.0m. (a) Develop an expression What is...
-
Create a program that will scrape the sayings from: https://quotes.toscrape.com/page/2/ Set up your program to allow the user to input a page number (1-10) which will return the quotes from that...
-
Labor productivity and the price of the good being produced are two variables that contribute to Multiple Choice O O O whether or not a union forms. the marginal product. the demand for the product....
-
Which of the following are not examples of a vicious cycle of deleveraging? Explain. a. Your university decides to sell several commercial buildings in the middle of town in order to upgrade...
-
A patient phones his pharmacist to inform her that he has started having serious problems swallowing, which he believes can be attributed to the drug he was recently prescribed. The pharmacist told...
-
Calculate the euro rates of return on the following assets: a. A painting whose price rises from 200,000 to 250,000 in a year. b. A diamond whose price rises from 20 000 to 21 000 between 2014 and...
-
Through the power of its purchasing cooperative and its nonprofit status, Mercy Hospitals pharmacy is able to purchase prescription drugs at much lower prices than community pharmacies. The director...
-
During the financial crisis in October 2008, the federal government could borrow at a rate of 2.73% (the yield on five-year Treasury securities). During October 2008, though, Baa borrowers (corporate...
-
Q. What are the main feature of mutations?
-
The Strahler Stream Order System ranks streams based on the number of tributaries that have merged. It is a top-down system where rivers of the first order are the headwaters (aka outermost...
-
This exercise provides practice in writing functions dealing with arrays and structures. The following is a program skeleton. Complete it by providing the described functions: #include using...
-
Whats the difference between an entry-condition loop and an exit-condition loop? Which kind is each of the C++ loops?
-
The Benevolent Order of Programmers maintains a collection of bottled port. To describe it, the BOP Portmaster has devised a Port class, as declared here: #include using namespace std; class Port {...
-
The group \(\mathrm{D}_{3}\) in Schoenflies notation (32 in international notation, which is read "three-two"; see Table 5.1 ) consists of the proper (those not reflections or inversions) covering...
-
Derive the two-dimensional matrix representation Tic)=(2) Tin)=(3) Tex)=(37) (69) T(c2b)= 1 TO)-(71) 10-(11) TO=(9) = for the group D3, using the basis (e1, e2) defined in the following figure.
-
Prove that the matrix representation of \(\mathrm{D}_{3}\) worked out in Problem 5.6 is irreducible. Data from Problem 5.6 Derive the two-dimensional matrix representation Tic)=(2) Tin)=(3)...
Study smarter with the SolutionInn App