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
Open the"stateData3.c" program and try to understand how the tokenization works. If you open the input file "stateData.txt", you
babymother [125]

Answer:

Kindly see explaination

Explanation:

Code

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#define size 200

int main(void)

{

int const numStates = 50;

char tempBuffer[size];

char tmp[size];

char fileName[] = "stateData.txt"; // Name of the text file (input file) which contains states and its populations

char outFile[] = "stateDataOutput1.txt"; // Output file name

// Open the input file, quit if it fails...

FILE *instream = fopen(fileName, "r");

/* Output File variable */

FILE *opstream;

if(instream == NULL) {

fprintf(stderr, "Unable to open file: %s\n", fileName);

exit(1);

}

//TODO: Open the output file in write ("w") mode

/* Opening output file in write mode */

opstream = fopen(outFile, "w");

//TODO: Read the file, line by line and write each line into the output file

//Reading data from file

while(fgets(tmp, size, instream) != NULL)

{

//Writing data to file

fputs(tmp, opstream);

}

// Close the input file

fclose(instream);

//TODO: Close the output file

/* Closing output file */

fclose(opstream);

return 0;

}

5 0
3 years ago
In using the drag coefficient care needs to be taken to use the correct area when determining the drag force. What is a typical
stealth61 [152]

Answer:

Explanation:

We know that Drag forceF_D

  F_D=\dfrac{1}{2}C_D\rho AV^2

Where

             C_D is the drag force constant.

                 A is the projected area.

                V is the velocity.

                ρ is the density of fluid.

Form the above expression of drag force we can say that drag force depends on the area .So We should need to take care of correct are before finding drag force on body.

Example:

 When we place our hand out of the window in a moving car ,we feel a force in the opposite direction and feel like some one trying to pull our hand .This pulling force is nothing but it is drag force.

6 0
3 years ago
Rubber bushings are used on suspensions to
Harlamova29_29 [7]
D. All of the above
4 0
3 years ago
A water supply agency is planning to add two reservoirs to its system. Water will flow from Reservoir A to Reservoir B via a 10,
NikAS [45]

Attached is the solution to the above question.

3 0
3 years ago
Air with a mass flow rate of 2.3 kg/s enters a horizontal nozzle operating at steady state at 450 K, 350 kPa, and velocity of 3
viktelen [127]

Answer:

Given that

Mass flow rate ,m=2.3 kg/s

T₁=450 K

P₁=350 KPa

C₁=3 m/s

T₂=300 K

C₂=460 m/s

Cp=1.011 KJ/kg.k

For ideal gas

P V = m R T

P = ρ RT

\rho_1=\dfrac{P_1}{RT_1}

\rho_1=\dfrac{350}{0.287\times 450}

ρ₁=2.71 kg/m³

mass flow rate

m= ρ₁A₁C₁

2.3 = 2.71 x A₁ x 3

A₁=0.28 m²

Now from first law for open system

h_1+\dfrac{C_1^2}{200}+Q=h_2+\dfrac{C_2^2}{2000}

For ideal gas

Δh = CpΔT

by putting the values

1.011\times 450+\dfrac{3^2}{200}+Q=1.011\times 300+\dfrac{460^2}{2000}

Q=1.011\times 300+\dfrac{460^2}{2000}-\dfrac{3^2}{200}-1.011\times 450

Q= - 45.49 KJ/kg

Q =- m x 45.49 KW

Q= - 104.67 KW

Negative sign indicates that heat transfer from air to surrounding

4 0
3 years ago
Other questions:
  • A 400-m^3 storage tank is being constructed to hold LNG, liquefied natural gas, which may be assumed to be essentially pure meth
    8·1 answer
  • A flocculation basin equipped with revolving paddles is 60 ft long (the direction of flow). 45 ft wide, and 14 ft deep and treat
    11·1 answer
  • (TCO 1) Name one disadvantage of fixed-configuration switches over modular switches. a. Ease of management b. Port security b. F
    6·1 answer
  • Crest is to high, as through is to
    12·2 answers
  • Both equilibrium equations and constitutive models are needed to solve statically indeterminate problems. a)- True b)-False
    13·1 answer
  • PLEASE HELP
    15·2 answers
  • 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
  • 1)
    13·1 answer
  • lmfsojdkkfjdsskfsaj;fkljsldfkjlsdkfdjs;dklfjsldkfjflkjfkjfldjsdlfgkljshglksdjfghdskjgsdfkfjghlsdfghsdkjfghlskjdfhglskjdfghkjsfhg
    12·1 answer
  • Select the correct answer.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!