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
The water requirement for Class H cement is 38% (i.e.,water (%) by weight of cement),whereas the water requirement for barite is
Vikentia [17]

Answer:

weight of barite = 398.4355 kg

Explanation:

Solution:- The values given in the question are as follows:

water requirement for H class cement = 38% by weight of cement

water requirement for barite = 2.4 gal / 100 lbm

H class cement slurry = 15.7 lbm/gal

one sack of cement = 50 kg or 110.231 lbm

one sack of cement require water = (38/100)*110.231

one sack of cement require water = 41.8877 gal

water required 100 lbm barite = 2.4 gal

or water required barite = 2.4% by weight of barite

H class cement slurry = (weight of cement + weight of barite)/total weight of water

15.7 =(110.231 + weight of barite)/(water required one sack of cement + 2.4%*weight of barite)

15.7 = 110.231 + (weight of barite)/(41.887 + 0.024*weight of barite)

15.7*41.8877 + 15.7*0.024*weight of barite = 110.231 + weight of barite

657.6368 + 0.3768*weight of barite = 110.231 + weight of barite

547.4058 =0.6232*weight of barite

weight of barite = 878.379 lbm or 878.4 lbm

weight of barite = 398.4355 kg

7 0
3 years ago
Earth whose in situ weight is 105lb/cf and whose compacted weight is 122 lb/cf is placed in a fill at the rate of 260 cy/hr, mea
Stells [14]

Answer:

Number of rollers required to complete the compaction are 2

Explanation:

The solution is given in the attachments.

6 0
3 years ago
Methane and oxygen react in the presence of a catalyst to form formaldehyde. In a parallel reaction, methane is oxidized to carb
Nezavi [6.7K]

Answer:

y_{CH_4}^2=\frac{5mol/s}{100mol/s}=0.05\\y_{O_2}^2=\frac{3mol/s}{100mol/s}=0.03\\y_{H_2O}^2=\frac{47mol/s}{100mol/s}=0.47\\y_{HCHO}^2=\frac{43mol/s}{100mol/s}=0.43\\y_{CO_2}^2=\frac{2mol/s}{100mol/s}=0.02

Explanation:

Hello,

a. On the attached document, you can see a brief scheme of the process. Thus, to know the degrees of freedom, we state the following unknowns:

- \xi_1 and \xi_2: extent of the reactions (2).

- F_{O_2}^2, F_{CH_4}^2, F_{H_2O}^2, F_{HCHO}^2 and F_{CO_2}^2: Molar flows at the second stream (5).

On the other hand, we've got the following equations:

- F_{O_2}^2=50mol/s-\xi_1-2\xi_2: oxygen mole balance.

- F_{CH_4}^2=50mol/s-\xi_1-\xi_2: methane mole balance.

- F_{H_2O}^2=\xi_1+2\xi_2: water mole balance.

- F_{HCHO}^2=\xi_1: formaldehyde mole balance.

- F_{CO_2}^2=\xi_2: carbon dioxide mole balance.

Thus, the degrees of freedom are:

DF=7unknowns-5equations=2

It means that we need two additional equations or data to solve the problem.

b. Here, the two missing data are given. For the fractional conversion of methane, we define:

0.900=\frac{\xi_1+\xi_2}{50mol/s}

And for the fractional yield of formaldehyde we can set it in terms of methane as the reagents are equimolar:

0.860=\frac{F_{HCHO}^2}{50mol/s}

In such a way, one realizes that the output formaldehyde's molar flow is:

F_{HCHO}^2=0.860*50mol/s=43mol/s

Which is equal to the first reaction extent \xi_1, therefore, one computes the second one from the fractional conversion of methane as:

\xi_2=0.900*50mol/s-\xi_1\\\xi_2=0.900*50mol/s-43mol/s\\\xi_2=2mol/s

Now, one computes the rest of the output flows via:

- F_{O_2}^2=50mol/s-43mol/s-2*2mol/s=3mol/s

- F_{CH_4}^2=50mol/s-43mol/s-2mol/s=5mol/s

- F_{H_2O}^2=43mol/s+2*2mol/s=47mol/s

- F_{HCHO}^2=43mol/s

- F_{CO_2}^2=2mol/s

The total output molar flow is:

F_{O_2}+F_{CH_4}+F_{H_2O}+F_{HCHO}+F_{CO_2}=100mol/s

Therefore the output stream composition turns out into:

y_{CH_4}^2=\frac{5mol/s}{100mol/s}=0.05\\y_{O_2}^2=\frac{3mol/s}{100mol/s}=0.03\\y_{H_2O}^2=\frac{47mol/s}{100mol/s}=0.47\\y_{HCHO}^2=\frac{43mol/s}{100mol/s}=0.43\\y_{CO_2}^2=\frac{2mol/s}{100mol/s}=0.02

Best regards.

7 0
3 years ago
For a steel alloy it has been determined that a carburizing heat treatment of 15 h duration will raise the carbon concentration
Free_Kalibri [48]

Answer:

135 hour

Explanation:

It is given that a carburizing heat treatment of 15 hour will raise the carbon concentration by 0.35 wt% at a point of 2 mm from the surface.

We have to find the time necessary to achieve the same concentration at a 6 mm position.

we know that \frac{x_1^2}{Dt}=constant where x is distance and t is time .As the temperature is constant so D will be also constant

So \frac{x_1^2}{t}=constant

then \frac{x_1^2}{t_1}=\frac{x_2^2}{t_2} we have given x_1=2 mm\ ,t_1=15 hour\ ,x_2=6\ mm and we have to find t_2 putting all these value in equation

\frac{2^2}{15}=\frac{6^2}{t_2}

so t_2=135\ hour

5 0
3 years ago
A simply supported wood roof beam is loaded with single point dead and roof live loads applied at midspan (PD = 400 lb, PLr = 16
Lynna [10]

Answer:mold i belive

Explanation:

3 0
3 years ago
Other questions:
  • During the collision, is the magnitude of the force of asteroid A on asteroid B greater than, less than, or equal to the magnitu
    11·2 answers
  • What is the first step in the problem-solving process, as well as in the engineering design process?
    7·1 answer
  • The reverse water-gas shift (RWGS) reaction is an equimolar reaction between CO2 and H2 to form CO and H2O. Assume CO2 associati
    10·1 answer
  • A rectangular block having dimensions 20 cm X 30 cm X 40 cm is subjected to a hydrostatic stress of -50 kPa (i.e. under compress
    15·1 answer
  • The density of a certain material is such that it weighs 9 pounds per cubic foot of
    10·1 answer
  • Part A What is the correct expression of the internal torque in segment AB? A shaft is fixed at A. A clockwise distributed torqu
    6·1 answer
  • Mobility refers to the ability to?
    12·1 answer
  • Similarity of surface<br>and ground<br>waler​
    9·1 answer
  • Determine the slopes and deflections at points B and C for the beam shown below by the moment-area method. E=constant=70Gpa I=50
    10·1 answer
  • EverFi future smart pie chart
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!