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
A piston–cylinder device contains a mixture of 0.5 kg of H2 and 1.2 kg of N2 at 100 kPa and 300 K. Heat is now transferred to th
Taya2010 [7]

Answer:

(a) The heat transferred is 2552.64 kJ    

(b) The entropy change of the mixture is 1066.0279 J/K

Explanation:

Here we have

Molar mass of H₂ = 2.01588 g/mol

Molar mass of N₂ = 28.0134 g/mol

Number of moles of H₂ = 500/2.01588  = 248 moles

Number of moles of N₂ = 1200/28.0134 = 42.8 moles

P·V = n·R·T

V₁ = n·R·T/P = 290.8×8.3145×300/100000 = 7.25 m³

Since the volume is doubled then

V₂ = 2 × 7.25 = 14.51 m³

At constant pressure, the temperature is doubled, therefore

T₂ = 600 K

If we assume constant specific heat at the average temperature, we have

Heat supplied = m₁×cp₁×dT₁ + m₂×cp₂×dT₂

 cp₁ = Specific heat of hydrogen at constant pressure = 14.50 kJ/(kg K

cp₂ = Specific heat of nitrogen at constant pressure = 1.049 kJ/(kg K

Heat supplied = 0.5×14.50×300 K+ 1.2×1.049×300 =  2552.64 kJ    

b)  \Delta S = - R(n_A \times lnx_A + n_B \times ln x_B)

Where:

x_A and x_B are the mole fractions of Hydrogen and nitrogen respectively.

Therefore, x_A = 248 /(248 + 42.8) = 0.83

x_B = 42.8/(248 + 42.8) = 0.1472

∴ \Delta S = - 8.3145(248 \times ln0.83 + 42.8 \times ln 0.1472) =  1066.0279 J/K

5 0
3 years ago
A total of 245 kip force is applied to a set of 10 similar bolts. If the spring constant of each bolt is 0.4 Mlb/in and that of
zubka84 [21]

Answer: The net force in every bolt is 44.9 kip

Explanation:

Given that;

External load applied = 245 kip

number of bolts n = 10

External Load shared by each bolt (P_E) = 245/10 = 24.5 kip

spring constant of the bolt Kb = 0.4 Mlb/in

spring constant of members Kc = 1.6 Mlb/in

combined stiffness factor C = Kb / (kb+kc) = 0.4 / ( 0.4 + 1.6)  = 0.4 / 2 = 0.2 Mlb/in

Initial pre load Pi = 40 kip

now for Bolts; both pre load Pi and external load P_E are tensile in nature, therefore we add both of them

External Load on each bolt P_Eb = C × PE = 0.2 × 24.5 = 4.9 kip

So Total net Force on each bolt Fb = P_Eb + Pi

Fb = 4.9 kip + 40 kip

Fb = 44.9 kip

Therefore the net force in every bolt is 44.9 kip

4 0
3 years ago
What camera battery does the canon 250d use?
Mila [183]

Answer:

The Canon EOS 250 is a digital DSLR that features a 24MP sensor. It is powered by the Canon LP-E17, which is a rechargeable Lithium-Ion battery pack.

Explanation:

8 0
2 years ago
Read 2 more answers
Radioactive wastes are temporarily stored in a spherical container, the center of which is buried a distance of 10 m below the e
a_sh-v [17]

Answer:

Outside temperature =88.03°C

Explanation:

Conductivity of air-soil from standard table

   K=0.60 W/m-k

To find temperature we need to balance energy

Heat generation=Heat dissipation

Now find the value

We know that for sphere

q=\dfrac{2\pi DK}{1-\dfrac{D}{4H}}(T_1-T_2)

Given that q=500 W

so

500=\dfrac{2\pi 2\times .6}{1-\dfrac{2}{4\times 10}}(T_1-25)

By solving that equation we get

T_2=88.03°C

So outside temperature =88.03°C

6 0
3 years ago
A section of a two-lane highway has 12-ft lanes and a design speed of 75 mi/h. The section contains a vertical curve and a horiz
spayn [35]

Answer:

Explanation: see attachment below

6 0
3 years ago
Other questions:
  • A turbine produces shaft power from a gas that enters the turbine with a (static) temperature of 628 K, a velocity of 143 m/s an
    7·1 answer
  • Please help me fast, I don’t have time
    15·1 answer
  • Technician A says that a magnetic field can be created by current flow. Technician B says that current can be induced by moving
    5·1 answer
  • In the 5 Code of Federal Regulations (C.F.R.), it is recommended that an individual has security awareness training before s/he
    8·2 answers
  • A level loop began and closed on BM_A (elevation = 823.368 ft). The plus and minus sights were kept approximately equal. Reading
    11·1 answer
  • What is the difference between a Datum and a Datum Feature? a) A Datum and Datum Feature are synonymous. b) A Datum is theoretic
    14·1 answer
  • 11. Which of the following is the brake fluid most often used?
    11·2 answers
  • Draw the six principal views of
    13·1 answer
  • Consider a single crystal of some hypothetical metal that has the FCC crystal structure and is oriented such that a tensile stre
    7·1 answer
  • Stress that acts in the plane of a cut section, rather than at right angles to the section is called:_______
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!