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
22 days 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 [274]22 days 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
You want to determine whether the race of the defendant has an impact on jury verdicts. You assign participants to watch a trial
grin007 [219]

Response:

The confidence scale is an ordinal measurement scale

Clarification:

An ordinal measurement scale is utilized for assessing attributes that can be ranked or ordered, yet the intervals in between attributes lack quantitative meaning. In this scenario, the scale utilized was from 1 to 7, where "1" signifies that the defendant's race has little impact on jury verdicts, and "7" indicates a strong impact of race on such verdicts. For instance, in a survey measuring customer satisfaction for a product, a "1" indicates great dissatisfaction, while "10 " denotes highest satisfaction. In the first instance, it would be incorrect to assert that the difference between a rating of 1, which implies "not at all," and perhaps a 3, is equivalent to the gap between a 5 and a 7, as these numbers merely serve as labels devoid of quantifiable value.

Other types of measurement levels include:

1. Nominal: This is the most straightforward measurement level, employed primarily for categorizing attributes. An example would be gathering data on gender, with categories such as male, female, and transgender.

2. Interval: An interval scale is used when the distances between two attributes hold meaning, but a true zero point is absent from the scale.

3. Ratio: This level combines all three previously mentioned measurements, serving to categorize, show ranking, maintain meaningful distances between attributes, and possess a true zero point. A typical example is measuring temperature using a Celsius thermometer, which has a true zero at 0°C, and the intervals between 5°C and 10°C are equivalent to those between 10°C and 15°C.

6 0
4 days ago
A technician has been dispatched to assist a sales person who cannot get his laptop to display through a projector. The technici
mote1985 [204]

Answer:Ensure the correct cable is connected between the laptop and the projector. Check for HDMI inputs or 15-pin video output interfaces.

Also, make sure the laptop is set to project to the correct display output.

Explanation:

7 0
21 day ago
Who want to play "1v1 lol unblocked games 76"
Daniel [215]

Answer:I want to know what game to play?

Explanation:

3 0
1 month ago
Read 2 more answers
Steam flows at steady state through a converging, insulated nozzle, 25 cm long and with an inlet diameter of 5 cm. At the nozzle
iogann1982 [279]

Answer:

The velocity at exit U_2 is 578.359 m/s

The exit diameter d_e is 1.4924 cm

Explanation:

Provided data includes:

Length of the nozzle L = 25 cm

Inlet diameter d_i = 5 cm

At the nozzle entrance (state 1): Temperature T_1 = 325 °C, Pressure P_1 = 700 kPa, Velocity U_1 = 30 m/s, Enthalpy H_1 = 3112.5 kJ/kg, Volume V_1 = 388.61 cm³/gAt the nozzle exit (state 2): Temperature T_2 = 250 °C, Pressure P_2 = 350 kPa, Velocity U_2, Enthalpy H_2 = 2945.7 kJ/kg, Volume V_2 = 667.75 cm³/g To determine:a. Exit Velocity U_2b. Exit Diameter d_e

a.The Energy Equation can be represented by:ΔH + ΔU² / 2 + gΔz = Q + WAssuming Q = W = Δz = 0Substituting the values yields:

(H_2 - H_1) + (U²_2 - U²_1)  / 2 = 0From which we can derive U_2 = sqrt((2* (H_1 - H_2 )) + U²_1) with the calculations leading to U_2 = sqrt ( 2 * 10^3 * (3112.5 -2945.7) + 900) yielding U_2 = 578.359 m/s

b.

Using mass balance approach, we have U_1 * A_1 / V_1 = U_2 * A_2 / V_2

Here, A = π*d² / 4

This leads to U_1 * d_i² / V_1 = U_2 * d_e² / V_2, thus d_e = d_i * sqrt((U_1 / U_2) * (V_2 / V_1)). Hence, d_e = 5 * sqrt((30 / 578.359) * (667.75 / 388.61)) computes to d_e = 1.4924 cm

6 0
5 days ago
Effects of biological hazards are widespread. Select the answer options which describe potential effects of coming into contact
pantera1 [220]

Answer:

- Allergic Responses

- Events Posing Life Threats

Explanation:

Biological hazards can originate from a variety of sources such as bacteria, viruses, insects, plants, birds, animals, and humans. These can lead to numerous health issues, which may range from skin allergies and irritations to infections (like tuberculosis or AIDS) and even cancer.

7 0
27 days ago
Other questions:
  • Write a function: def solution (S) that, given a string S of letters "L" and "R", denoting the types of shoes in line (left or r
    9·3 answers
  • As shown, a load of mass 10 kg is situated on a piston of diameter D1 = 140 mm. The piston rides on a reservoir of oil of depth
    9·1 answer
  • A certain full-wave rectifier has a peak output voltage of 30 V. A 50 mF capacitor-input filter is connected to the rectifier. C
    6·1 answer
  • Write multiple if statements. If car_year is 1969 or earlier, print "Few safety features." If 1970 or later, print "Probably has
    12·1 answer
  • All MOS devices are subject to damage from:________
    7·1 answer
  • A long, circular aluminum rod is attached at one end to a heated wall and transfers heat by convection to a cold fluid.
    12·1 answer
  • cubical tank 1 meter on each edge is filled with water at 20 degrees C. A cubical pure copper block 0.46 meters on each edge wit
    6·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
  • NEEDS TO BE IN PYTHON:ISBN-13 is a new standard for indentifying books. It uses 13 digits d1d2d3d4d5d6d7d8d910d11d12d13 . The la
    15·1 answer
  • 1. A four-lane freeway (two lanes in each direction) is located on rolling terrain and has 12-ft lanes, no lateral obstructions
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!