1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
jeka57 [31]
3 years ago
10

6.32 LAB: Exact change - functions

Engineering
1 answer:
Neko [114]3 years ago
5 0

Answer:

Below is the desired C++ program for the problem. Do feel free to edit it according to your preference

Explanation:

#include <iostream>

#include <vector>

using namespace std;

void ExactChange(int userTotal, vector<int> &coinVals) {

   coinVals.reserve(5);

   coinVals[0] = userTotal / 100;

   userTotal %= 100;

   coinVals[1] = userTotal / 25;

   userTotal %= 25;

   coinVals[2] = userTotal / 10;

   userTotal %= 10;

   coinVals[3] = userTotal / 5;

   userTotal %= 5;

   coinVals[4] = userTotal;

}

int main() {

   vector<int> coins;

   int value;

   cin >> value;

   if (value <= 0) {

       cout << "no change" << endl;

   } else {

       ExactChange(value, coins);

       if (coins[0] != 0) cout << coins[0] << " " << (coins[0] == 1 ? "dollar" : "dollars") << endl;

       if (coins[1] != 0) cout << coins[1] << " " << (coins[1] == 1 ? "quarter" : "quarters") << endl;

       if (coins[2] != 0) cout << coins[2] << " " << (coins[2] == 1 ? "dime" : "dimes") << endl;

       if (coins[3] != 0) cout << coins[3] << " " << (coins[3] == 1 ? "nickel" : "nickels") << endl;

       if (coins[4] != 0) cout << coins[4] << " " << (coins[4] == 1 ? "penny" : "pennies") << endl;

   }

   return 0;

}

You might be interested in
Railroad tracks made of 1025 steel are to be laid during the time of year when the temperature averages 4C (40F). Of a joint spa
DENIUS [597]

Answer:

41.5° C

Explanation:

Given data :

1025 steel

Temperature = 4°C

allowed joint space = 5.4 mm

length of rails = 11.9 m

<u>Determine the highest possible temperature </u>

coefficient of thermal expansion ( ∝ ) = 12.1 * 10^-6 /°C

Applying thermal strain ( Δl / l )  = ∝ * ΔT

                                    ( 5.4 * 10^-3 / 11.9 )  = 12.1 * 10^-6 * ( T2 - 4 )

∴  ( T2 - 4 ) =  ( 5.4 * 10^-3 / 11.9 ) / 12.1 * 10^-6

hence : T2 = 41.5°C

8 0
3 years ago
What would the Select lines need to be to send data for the fifth bit in an 8-bit system (S0 being the MSB and S2 being the LSB)
Maurinko [17]

Answer:

A. S0 = 1, S1 = 0, S2 = 0

lines need to send data for the fifth bit in an 8 bit system

5 0
3 years ago
Which physical quantity measures fraction of the input energy a machine actually concerts into output energy ?
Dvinal [7]
The answer is Kinetic Power.
4 0
3 years ago
A digital filter is given by the following difference equationy[n] = x[n] − x[n − 2] −1/4y[n − 2].(a) Find the transfer function
slega [8]

Answer:

y(z) = x(z) - x(z) {z}^{ - 2}  -  \frac{1}{4} y(z) {z}^{ - 2}  \\ y(z) + \frac{1}{4} y(z) {z}^{ - 2} = x(z) - x(z) {z}^{ - 2} \\ y(z) (1 + \frac{1}{4}{z}^{ - 2}) = x(z)(1 - {z}^{ - 2}) \\  h(z) = \frac{y(z)}{x(z)}  =  \frac{(1 + \frac{1}{4}{z}^{ - 2})}{(1 - {z}^{ - 2})}

The rest is straightforward...

6 0
3 years ago
Wright Company deposits all cash receipts on the day when they are received and it makes all cash payments by check. At the clos
alina1380 [7]

Answer:

                                              Wright Company

                                             Bank Reconciliation

                                                 May 31, 2013

Credit side                                                                                   Debit side

Bank statement $26200                 |                          Book balance $27900

<em>Add;                                                    </em>

Deposit on May 31 $6400

Bank error $420

Sub-total=$33020

Deductions;                                        |                       Deduct

ions

Outstanding checks $5800              |                 Bank service charge $120

Adjusted bank balance $27220       |                  NSF check $560

                                                                             Total deduction $680

                                                      Adjusted book balance $27220

8 0
3 years ago
Other questions:
  • Show how am MDP with a reward function R(s, a, s’) can be transformed into a different MDP with reward function R(s, a), such th
    15·1 answer
  • What are the two safety precautions taken before driving a car​
    12·1 answer
  • A resonant six-turn loop of closely spaced turns is operating at 50 MHz. The radius of the loop is λ/30, and the loop is connect
    15·1 answer
  • WHAT IS THE EFFECT OF ICE ACCRETION ON THE LONGITUDINAL STABILITY OF AN AIRCRAFT?
    8·1 answer
  • A. Derive linear density expressions for BCC [110] and [111] directions in terms of the atomic radius R.
    7·1 answer
  • The difference in quantity between the add and full marks on an engine oil dipstick is typically
    5·1 answer
  • QUESTION:
    15·1 answer
  • Find the remaining trigonometric function of 0 if
    13·1 answer
  • Plz help electrical technology
    15·2 answers
  • A design that either partially or wholly integrates the bodywork
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!