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
ArbitrLikvidat [17]
3 years ago
15

Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per li

ne. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies.
Engineering
1 answer:
pshichka [43]3 years ago
6 0

Answer:

The C code is given below with appropriate comments

Explanation:

#include<stdio.h>

//defining constants

#define DOLLAR 100

#define QUARTER 25

#define DIME 10

#define NICKEL 5

#define PENNIES 1

//converting method

void ExactChange(int userTotal,int coinVals[])

{

//checking dollars

if (userTotal >=100)

{

coinVals[0]=userTotal/DOLLAR;

userTotal=userTotal-(100*coinVals[0]);

}

//checking quarters

if (userTotal >=25)

{

coinVals[1]=userTotal/QUARTER;

userTotal=userTotal-(25*coinVals[1] );

}

//checking dimes

if (userTotal >=10)

{

coinVals[2]=userTotal/DIME;

userTotal=userTotal-(10*coinVals[2]);

}

//checking nickels

if (userTotal >=5)

{

coinVals[3]=userTotal/NICKEL;

userTotal=userTotal-(5*coinVals[3]);

}

//checking pennies

if (userTotal >=1)

{

coinVals[4]=userTotal/PENNIES;

userTotal=userTotal-coinVals[4];

}

}

//main method

int main() {

//defining the variables

int amount;

//asking for input

printf("Enter the amount in cents :");

//reading the input

scanf("%d",&amount);

//validating the input

if(amount<1)

{

//printing the message

printf("No change..!");

}

//when the input is >0

else

{

int coinVals[5]={0,0,0,0,0};

ExactChange(amount,coinVals);

//checking dollars

if (coinVals[0]>0)

{

//printing dollars

printf("%d Dollar",coinVals[0]);

if(coinVals[0]>1) printf("s");

}

//checking quarters

if (coinVals[1]>0)

{

//printing quarters

printf(" %d Quarter",coinVals[1]);

if(coinVals[1]>1) printf("s");

}

//checking dimes

if (coinVals[2]>0)

{

//printing dimes

printf(" %d Dime",coinVals[2]);

if(coinVals[2]>1) printf("s");

}

//checking nickels

if (coinVals[3]>0)

{

//prinitng nickels

printf(" %d Nickel",coinVals[3]);

if(coinVals[3]>1) printf("s");

}

//checking pennies

if (coinVals[4]>0)

{

//printing pennies

printf(" %d Penn",coinVals[4]);

if(coinVals[4]>1) printf("ies");

else printf("y");

}

}

//end of main method

}

You might be interested in
Carnot heat engine A operates between 20ºC and 520ºC. Carnot heat engine B operates between 20ºC and 820ºC. Which Carnot heat en
nikklg [1K]

Answer:

engine B is more efficient.

Explanation:

We know that Carnot cycle is an ideal cycle for all working heat engine.In Carnot cycle there are four processes in which two are constant temperature processes and others two are isentropic process.

We also kn ow that the efficiency of Carnot cycle given as follows  

\eta =1-\dfrac{T_1}{T_2}

Here temperature should be in Kelvin.

For engine A

\eta =1-\dfrac{T_1}{T_2}

\eta =1-\dfrac{273+20}{520+273}

\eta =0.63

For engine B

\eta =1-\dfrac{T_1}{T_2}

\eta =1-\dfrac{273+20}{820+273}

\eta =0.73

So from above we can say that engine B is more efficient.

4 0
4 years ago
Calculate the electroosmotic velocity of an aqueous solution through a glass capillary 5 cm long with a 0.5 mm internal diameter
natita [175]

Answer:

Electroosmotic velocity will be equal to 1.6\times 10^{-4}m/sec

Explanation:

We have given applied voltage v = 100 volt

Length of capillary L = 5 mm = 0.005 m

Zeta potential of the capillary surface \xi =80mV=0.08volt

Dielectric constant of glass is between 5 to 10 here we are taking dielectric constant as \epsilon =10

Viscosity of glass is \eta =10^8

Electroosmotic velocity is given as v_{eo}=\frac{\epsilon \xi }{\eta }\times \frac{v}{L}

v_{eo}=\frac{10\times 0.08 }{10^8 }\times \frac{100}{0.005}=1.6\times 10^{-4}m/sec

So Electroosmotic velocity will be equal to 1.6\times 10^{-4}m/sec

8 0
4 years ago
What is the difference between filler and electrode in Welding? Can a filler be an electrode? Can an electrode be a filler? Why?
Vlada [557]

Explanation:

<u>Filler:</u>

  Filler is the material rod is used when we are joining two material by using welding process.If thickness of work piece is more so it will become compulsory to provide some filler material for making the welding join to withstand high stresses.

<u>Electrode:</u>

  Electrode is the element which is used to complete the electric circuit in welding .Some time electrode is connected with positive terminal and some time with negative terminal ,it depends on the requirement of welding process.In Tungsten inert gas welding electrode is connected negative terminal but on the other hand Metal inert gas welding electrode is connected with positive terminal.Electrode can be consumable non-consumable depends on the condition.

Yes electrode can be work as filler material ,in Metal inert gas welding wire is used as electrode as well as filler material.In Metal inert gas welding consumable electrode is used on the other hand Tungsten inert gas welding non-consumable electrode is used.In Tungsten inert gas welding if thickness of work pieces is less than 5 mm then no need to used any filler material but if thickness is more than 5 mm then we have to use filler material.

8 0
3 years ago
A 10 hp motor is used to raise a 1000 Newton weight at a vertical distance of 5 meters. What is the work the motor performs?
Aleksandr [31]

The work done by a 10 HP motor when it raises a 1000 Newton weight at a vertical distance of 5 meters is <u>5kJ</u>.

Define work. Explain the rate of doing work.

Work is <u>the energy that is moved to or from an item by applying force along a displacement</u> in physics. For a constant force acting in the same direction as the motion, work is <u>easiest expressed as the product of </u><u>force </u><u>magnitude and distance traveled</u>.

Since the <u>force </u><u>transfers one unit of energy for every unit of </u><u>work </u><u>it performs</u>, the rate at which work is done and energy is used are equal.

Solution Explained:

Given,

Weight = 1000N and distance = 5m

A/Q, the work here is done in lifting then

Work = (weight) × (distance moved)

         = 1000 X 5

         = 5000Nm or 5000J = 5kJ

Therefore, the work done in lifting a 1000 Newton weight at a vertical distance of 5 meters is 5kJ.

To learn more about work, use the link given
brainly.com/question/25573309
#SPJ9

<u />

4 0
1 year ago
What is thermodynamics system? Briefly explain (i) control mass system (ii) control volume system. Comment briefly on control ma
olga2289 [7]

Explanation:

Thermodynamics system :

 Thermodynamics system is a region or space in which study of matters can be done.The system is separated from surroundings by a boundary this boundary maybe flexible or fixed it depends on situations.The out side the system is called surroundings.

Generally thermodynamics systems are of three types

1.Closed system(control mass system)

  Only energy transfer take place ,no mass transfer take place.

2.Open system(control volume system)

 Both mass as well as energy transfer take place.

3.Isolated system

   Neither mass or nor energy transfer take place.

At steady state ,property is did not changes with respect to time.

3 0
3 years ago
Other questions:
  • I am trying to create a line of code to calculate distance between two points. (distance=[tex]\sqrt{ (x2-x1)^2+(y2-y1)^2}) My li
    5·1 answer
  • An op-amp is connected in an inverting configuration with R1 = 1kW and R2 = 10kW, and a load resistor connected at the output, R
    9·1 answer
  • A stainless-steel specimen from the same material characterized up above, was formed into a rectangular cross-section of dimensi
    9·1 answer
  • An eddy current separator is to separate aluminum product from an input streamshredded MSW. The feed rate to the separator is 2,
    7·1 answer
  • Can someone help plz?!?
    5·2 answers
  • How many trains have been invented all around the world?
    14·1 answer
  • Water from an upper tank is drained into a lower tank through a 5 cm diameter iron pipe with roughness 2 mm. The entrance to the
    11·1 answer
  • The Imager for Mars Pathfinder (IMP) is an imaging system. It has two camera channels. Each channel has color capability. This i
    7·1 answer
  • A ____ is either in the pressure reducer or in the downstream side of the system to ensure that the control air pressure does no
    15·1 answer
  • Which pipe for water is best for construction?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!