answer.
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
Oxana
2 months 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:
alex41 [359]2 months ago
6 0

Answer:

The following is the C code annotated with suitable comments.

Explanation:

#include<stdio.h>

//constants defined

#define DOLLAR 100

#define QUARTER 25

#define DIME 10

#define NICKEL 5

#define PENNIES 1

//method for converting

void ExactChange(int userTotal,int coinVals[])

{

//dollar calculation

if (userTotal >=100)

{

coinVals[0]=userTotal/DOLLAR;

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

}

//quarter analysis

if (userTotal >=25)

{

coinVals[1]=userTotal/QUARTER;

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

}

//dime check

if (userTotal >=10)

{

coinVals[2]=userTotal/DIME;

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

}

//nickel check

if (userTotal >=5)

{

coinVals[3]=userTotal/NICKEL;

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

}

//pennies check

if (userTotal >=1)

{

coinVals[4]=userTotal/PENNIES;

userTotal=userTotal-coinVals[4];

}

}

//main function

int main() {

//variables defined

int amount;

//requesting user input

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

//input registration

scanf("%d",&amount);

//input validation

if(amount<1)

{

//output message

printf("No change..!");

}

//if the input is positive

else

{

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

ExactChange(amount,coinVals);

//checking for dollars

if (coinVals[0]>0)

{

//output for dollars

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

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

}

//checking quarters

if (coinVals[1]>0)

{

//output for quarters

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

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

}

//checking dimes

if (coinVals[2]>0)

{

//output for dimes

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

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

}

//checking nickels

if (coinVals[3]>0)

{

//printing 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 the main function

}

You might be interested in
Michelle is the general manager of a power plant. This morning, she will meet with city officials to discuss environmental issue
grin007 [323]
interpersonal. Among all of Michelle's activities, three require her interpersonal skills. These include meeting with city officials, conferring with section managers, and addressing a complaint brought forth by an employee. Therefore, the majority of her day revolves around utilizing these interpersonal skills.
6 0
1 month ago
At what forward voltage does a diode conduct a current equal to 10,000 Is ? In terms of Is , what current flows in the same diod
pantera1 [306]

Answer:a) The forward voltage is 0.23 V

b) The current that flows  

I_{d} = (1.45*10^{12}I_{s})A

Explanation:

The forward voltage refers to the minimum voltage required for a diode to start conducting. The formula used is given by:

a) At which forward voltage does a diode allow a current equal to 10,000 Is? In terms of Is

I_{d} = I_{s}(e^{\frac{v_{f} }{0.025} }-1)

Where:

Id denotes the diode current = 10000Is,

Vd stands for the forward voltage at which conduction begins,

Is indicates the saturation current.

I_{d} = I_{s}(e^{\frac{v_{f} }{0.025} }-1)

10000I_{s} = I_{s}(e^{\frac{v_{f} }{0.025} }-1)

By dividing through by Is,

10000 = (e^{\frac{v_{f} }{0.025} }-1)

10000 +1= e^{\frac{v_{f} }{0.025} }

10001= e^{\frac{v_{f} }{0.025} }

Taking the natural log of both sides,

ln(10001)= {\frac{v_{f} }{0.025} }

9.21= {\frac{v_{f} }{0.025} }

Multiplying through by 0.025 yields  

= 0.23 V

This indicates the forward voltage at which the diode conducts a current equal to 10,000 Is is 0.23 V

b) What current flows in the same diode when the forward voltage is 0.7 V?

I_{d} = I_{s}(e^{\frac{v_{f} }{0.025} }-1)

I_{d} = I_{s}(e^{\frac{0.7}{0.025} }-1)

I_{d} = I_{s}(1.45*10^{12} -1)

I_{d} = (1.45*10^{12}I_{s})A

6 0
1 month ago
All MOS devices are subject to damage from:________
Viktor [391]

Answer:

d. all of these

Explanation:

Electrostatic discharge typically generates a high voltage in a localized area, leading to increased current and heat. It can create craters in an MOS device, damage bond wires, or result in other forms of impairment. Essentially, MOS devices are vulnerable to harm from "all of these."

6 0
2 months ago
Consider the following program:
Daniel [329]

Answer:

The resolution for this question is below in the explanation section.

Explanation:

The right response to this question is A, which is 112002.

The correct code relating to this question is presented below

#include  <stdio.h>

#include  <string.h>

#include  <sys/types.h>

//#include "csapp.h"

void end(void)

{

printf("2");

}

int main()

{

if (fork() == 0)

atexit(end);

if (fork() == 0)

printf("0");

else

printf("1");

exit(0);

}

/* $end forkprob2 */

When this program is executed, the fork function will yield varying results.

However, it should be noted that running it multiple times will produce inconsistent values. The most common output the program will generate is A.

Attached is an image of the program's execution for further clarification.

5 0
1 month ago
Other questions:
  • A Carnot heat engine receives heat from a reservoir at 900oC at a rate of 800 kJ/min and rejects the waste heat to the ambient a
    13·1 answer
  • Two streams flow into a 500.0-gallon tank. The first stream is 10.0 wt % ethanol and 90.0 wt% hexane (mixture density is rho1 0.
    15·1 answer
  • A pitfall cited in Section 1.10 is expecting to improve the overall performance of a computer by improving only one aspect of th
    6·1 answer
  • Consider a very long, slender rod. One end of the rod is attached to a base surface maintained at Tb, while the surface of the r
    8·1 answer
  • Marble A is placed in a hollow tube, and the tube is swung in a horizontal plane causing the marble to be thrown out. As viewed
    11·1 answer
  • 1. A glass window of width W = 1 m and height H = 2 m is 5 mm thick and has a thermal conductivity of kg = 1.4 W/m*K. If the inn
    8·1 answer
  • The pressure drop across a valve through which air flows is expected to be 10 kPa. If this differential were applied to the two
    11·1 answer
  • Bananas are to be cooled from 28°C to 12°C at a rate of 1140 kg/h by a refrigerator that operates on a vapor-compression refrige
    6·1 answer
  • A thermocouple element when taken from a liquid at 50°C and plunged into a liquid at 100° C at time t = 0 gave the following e.m
    11·1 answer
  • A single-phase load is located 2800 ft from its source. The load draws a current of 86 A and operated on 480 V. The maximum volt
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!