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
7. Which of the following is a disadvantage of an electromagnet?
Sati [7]

Answer:

I think

electromagnets require power to operate

7 0
3 years ago
Consider the formation of p-nitrophenol from p-nitrophenyl trimethyl acetate. The process is known as enzymatic hydrolysis and i
solniwko [45]

Solution :

cs=zeros(9001);

ca=zeros(9001);

cp=zeros(9001);

psi=zeros(9001);

t=[0:0.1:900];

cs(1)=0.5;

ce(1)=0.001;

cp(1)=0;

ca(1)=0;

psi(1)=0;

for i=1:1:9000

cs(i+1)=cs(i)-0.1*((0.015*cs(i))/(5.53+cs(i)));

cp(i+1)=cp(i)+0.1*((0.015*cs(i))/(5.53+cs(i))-0.0026*cp(i));

ca(i+1)=ca(i)+0.1*0.0026*cp(i);

psi(i+1)=((cp(i+1)-cp(i)))/((cs(i)-cs(i+1)));

end

plot(t,cs,t,cp,t,ca);

plot(t,psi);

6 0
3 years ago
If 1 inch equals 10 feet, what would the measured distance be if the line scaled 1 1/2 inches?
Crank

Answer: B. 15 feet

Explanation:

4 0
3 years ago
Read 2 more answers
IDENTIFY THE POINTER READING FOR EACH SCALE. COMPUTE THE READING USING THE ASSIGNED RANGE MULTIPLIER FOR OHMMETER SCALE.
daser333 [38]

Answer:

https://gltnhs-tle.weebly.com › lesso...

Web results

Lesson 2 - T.L.E Learning Module

3 0
3 years ago
Read 2 more answers
Write a java program which will produce the following output. No variables are needed but the program must use numbers and math
Sav [38]

The question did not include the output to be produced. However, below are the outputs.

My age is 21

Twice my age is 42

Three times my age is 63

ANSWER:

public class NewClasss{

   public static void main(String[] args) {

   int x,y,z;

   x = 21;

   y = 2*x;

   z=3*x;

   System.out.println("My age is " + x);

   System.out.println("twice my age is " + y);

   System.out.println("three times my age is " + z);

   

   }

  }

8 0
3 years ago
Other questions:
  • A two-fluid heat exchanger has inlet and outlet temperatures of 65 and 40 degree C for the hot fluid and 15 and 30 degree C for
    9·1 answer
  • Air enters the compressor of an ideal cold air-standard Brayton cycle at 100 kPa, 300 K, with a mass flow rate of 6 kg/s. The co
    11·1 answer
  • Two kilograms of oxygen fills the cylinder of a piston-cylinder assembly. The initial volume and pressure are 2 m3 and 1 bar, re
    6·2 answers
  • Use deep neural networks (you may use any free deep learning software tool) to perform a binary classification task, show final
    6·1 answer
  • Chemical resistant aprons for use while working around pesticides should.? A. Be made of solvent resistant leather B. Cover the
    6·1 answer
  • Airflow through a long, 0.15-m-square air conditioning duct maintains the outer duct surface temperature at 10°C. If the horizon
    11·1 answer
  • the diagram shows an electrical circuit when the switch is open and closed which series of energy transformation occurs when the
    15·1 answer
  • A hydraulic cylinder pushes a heavy tool during the outward stroke, placing a compressive load of 400Ib in the piston rod. Durin
    14·1 answer
  • Calculate the resistance of a circuit with 1.5 A and 120 V. Use the appropriate formula from the list of formulas on the
    9·1 answer
  • From the top of a vertical cliff 80m high, the angles of depression of 2 buoys lying due west of the cliff are 23° and 15° respe
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!