Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please convert this into code using the most BASIC C++ code. Thank You. Declare variables ones,fives,tens,twnties,fifties,hundreds,salesCnt,openingBal,salesAmt,deposit,paidAmt,i=1,Diff Prompt Enter 1's in opening cash: Read ones

Please convert this into code using the most BASIC C++ code. Thank You.

  • Declare variables ones,fives,tens,twnties,fifties,hundreds,salesCnt,openingBal,salesAmt,deposit,paidAmt,i=1,Diff
  • Prompt "Enter 1's in opening cash: "
  • Read ones
  • Prompt "Enter 5's in opening cash: "
  • Read fives
  • Prompt "Enter 10s in opening cash: "
  • Read tens
  • Prompt "Enter 20's in opening cash: "
  • Read twenties
  • Prompt "Enter 50's in opening cash: "
  • Read fifties
  • Prompt "Enter 100's in opening cash: "
  • Read hundreds
  • Calculate Opening balance

openingBal=ones+fives+tens+twenties+fifties+hundreds

  • Copy deposit, deposit=deposit+openingBal
  • Generate random sales count of the day

salesCnt=rand()%20+1

While i <=salesCnt

Prompt "Enter the amount sales i: "

Read salesAmt

IF salesAmt<0

Display Error Message less than 0

ELSE IF salesAmt>100

Display Error Message greater than 100

ELSE

Prompt "Enter the amount paid: "

Read paidAmt

IF paidAmt<0

Display Error Message less than 0

ELSE IF paidAmt>100

Display Error Message greater than 100

ELSE IF paidAmt

Display Error Message not enough

ELSE

diff=paidAtmt-salesAmt

IF diff>0:

IF diff==1:

ones-=1

ELSE IF diff=5

fives-=1

ELSE IF diff=10

tens-=1

ELSE IF diff=20

twenties-=1

ELSE IF diff=50

ffties-=1

ELSE IF diff=100

hundreds-=1

IF paidAmt==1:

ones+=1

ELSE IF paidAmt=5

fives+=1

ELSE IF paidAmt=10

tens+=1

ELSE IF paidAmt=20

twenties+=1

ELSEIF paidAmt=50

ffties+=1

ELSE IF paidAmt=100

hundreds+=1

deposit+=diff

i=i+1

End While

  • Display end of the day details

deposit=deposit-75

Display deposit

twenties-=2

tens-=3

fives-=4

ones-=5

Display hundreds,fifties,twenties,tens,fives and ones

Display cash drawer = 75

Display cash drawer ones=5,fives=4,tens=2,twenties=2,fifties=0,hundred=0

________________________________________________________________________________________________

Please us this information to understand what the above code needs to do. Thank you.

Program

The program should start by asking the employee for the amount of money in the opening cash drawer. The program will need to keep track of the number of $1s, $5s, $10s, $20s, $50s, and $100s. The store keeps only dollars (no cents).

Next, the daily sales will take place. Please use a random number generator to tell us how many sales will be taking place during the day and the amount of each sale (usually no more than 20 sales take place in a day). You can limit items for sale to be only whole numbers (no cents) and all are under $100. Only cash sales affect the cash drawer (charges with a visa or debit card are not used). See below for an explanation of how to use the random number generator.

Then, when the daily sales have been completed, have the program calculate how much to deposit in the bank, leaving somewhere between somewhere between $70 and $85 dollars in the cash drawer with appropriate denominations. You will want to work on the algorithm for this section in detail. (Saying Calculate Deposit will not give you enough detail to solve this problem!) The output at the end should be the amount to deposit and the total amount left in the cash drawer along with the number of each demonization for the next day.

Random Numbers: In this program you will need to use the random number generator. There are two function needed to use this from the cstdlib library (standard library header file) and ctime: srand(time(0)); to seed the random number generator at the beginning of your program (i.e., at the beginning inside of main() ) rand() which will return a random number when you need it: value = rand(); The mod operation (%) is great to limit the value returned from the random number generator, such as limiting the number to a range of 1-100. variable = some_number % maximum +1; The % gives you the remainder (which is what is left over after an integer division).

Things you should know...as part of the program: 1. Make sure to use a loop. 2. Make sure to prompt the user for any input requested. Make sure it is clear from your prompts what the user is expected to do. 3. Please don't use any global variables in this program! 4. Make sure to use C++s I/O (iostream library) for I/O 5. And, dont forget to add comments and to work on your programs readability

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How do agency relationships arise? AppendixLO1

Answered: 1 week ago