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
An astronomer of 65 kg of mass hikes from the beach to the observatory atop the mountain in Mauna Kea, Hawaii (altitude of 4205
lara [203]

Answer:

0.845\ \text{N}

Explanation:

g = Acceleration due to gravity at sea level = 9.81\ \text{m/s}^2

R = Radius of Earth = 6371000 m

h = Altitude of observatory = 4205 m

Change in acceleration due to gravity due to change in altitude is given by

g_h=g(1+\dfrac{h}{R})^{-2}\\\Rightarrow g_h=9.81\times(1+\dfrac{4205}{6371000})^{-2}\\\Rightarrow g_h=9.797\ \text{m/s}^2

Weight at sea level

W=mg\\\Rightarrow W=65\times 9.81\\\Rightarrow W=637.65\ \text{N}

Weight at the given height

W_h=mg_h\\\Rightarrow W_h=65\times 9.797\\\Rightarrow W_h=636.805\ \text{N}

Change in weight W_h-W=636.805-637.65=-0.845\ \text{N}

Her weight reduces by 0.845\ \text{N}.

8 0
3 years ago
Which band has an average of $3.58 per hour of parking?
Minchanka [31]
C it would be c because that has more and the others have less
6 0
2 years ago
What is Elon Musk mad about?
boyakko [2]

Answer:

Tesla CEO Elon Musk tweeted that the company's stock was too high, and it immediately dropped in value. The tweet may have violated a deal Musk made with the SEC about his tweets and Tesla. Musk also tweeted patriotic lyrics, said his girlfriend Grimes is mad at him, and noted that their child is due on Monday

6 0
3 years ago
جائت فكرة ربط الحواسيب لغرض نقل البيانات و مشاركتها و بعدها بفتره قصيره جائت إمكانية مشاركة الموارد بين الحواسيب صح ام خطأ​
melamori03 [73]

Answer:

بدلاً من ذلك يُشار إليه باسم مشاركة أو مشاركة شبكة ، الدليل المشترك هو دليل أو مجلد يمكن الوصول إليه من قبل العديد من المستخدمين على الشبكة. هذه هي الطريقة الأكثر شيوعًا للوصول إلى المعلومات ومشاركتها على شبكة محلية

Explanation:

5 0
3 years ago
Read 2 more answers
blank lines are used to see inside the product?blank lines are used to see inside the product what are they called ​
mixer [17]

Answer:

Do you have anymore information about this?

7 0
3 years ago
Other questions:
  • Main technologies used in atms vending machines game consoles and microwave ovens
    6·1 answer
  • An inventor tries to sell you his new heat engine that takes in 40 J of heat at 87°C on each cycle, expels 30 J at 27°C, and doe
    14·1 answer
  • A simple Rankine cycle coal-fired power plant has given states identified in the following table. The power plant produces 2.1 b
    9·1 answer
  • In a flow over a flat plate, the Stanton number is 0.005: What is the approximate friction factor for this flow a)- 0.01 b)- 0.0
    8·1 answer
  • Answer the question faster please
    7·1 answer
  • The image shows the relative positions of Earth and the Sun for each of the four seasons. Earth travels in an elliptical orbit a
    11·2 answers
  • Tech A says that a mechanical pressure regulator exhausts excess fluid back to the transmission pan. Tech B says that if the tra
    9·1 answer
  • 1. Làm thế nào để đảm bảo tính khả thi của văn bản hành chính ?
    12·1 answer
  • How do you get your drivers lisnes when your 15
    8·1 answer
  • Instructions: For each problem, identify the appropriate test statistic to be use (t test or z-test). Then compute z or t value.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!