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
ArbitrLikvidat [17]
2 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]2 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
The molecular weight of a 10g rubber band
Archy [21]

Answer:

The answer to this question is 1 * 10g /mole = 10

Explanation:

From the question given, the first step to take is to find the weight of a 10g rubber band.

Now,

The molecular weight of rubber band , tires the primary chains may have molecular weights is of order of 1 x 10 g/

Therefore it is 1 * 10g/mole =10

8 0
2 years ago
A particle has an initial velocity of v0 = 14 ft/s to the right, at s0 = 0, and a = 2 ft/s2 to the left. determine its position
Irina18 [472]

Answer:

The particle is 40 m to the right of its initial position.

Explanation:

Given data

  • Initial velocity (v₀): 14 ft/s (in direction to the positive x-axis)
  • Initial position (s₀): 0 m
  • Acceleration (a): -2 ft/s² (in direction to the negative x-axis)

We can determine the position of the particle at a time t = 10 s, using the following kinematic expression.

s = s₀ + v₀.t + 1/2.a.t²

s(10) = 0 m + 14 ft/s × 10 s + 1/2 × (-2 ft/s²) × (10 s)²

s = 40 m

The particle is 40 m to the right of its initial position.

6 0
2 years ago
Vehicles arrive at a single toll booth beginning at 8:00 A.M. They arrive and depart according to a uniform deterministic distri
jok3333 [9.3K]

Answer:

Explanation:

answers attached bellow

6 0
2 years ago
A plate of an alloy steel has a plane-strain fracture toughness of 50 MPa√m. If it is known that the largest surface crack is 0.
Ivahew [28]

Answer:

option B is correct. Fracture will definitely not occur

Explanation:

The formula for fracture toughness is given by;

K_ic = σY√πa

Where,

σ is the applied stress

Y is the dimensionless parameter

a is the crack length.

Let's make σ the subject

So,

σ = [K_ic/Y√πa]

Plugging in the relevant values;

σ = [50/(1.1√π*(0.5 x 10^(-3))]

σ = 1147 MPa

Thus, the material can withstand a stress of 1147 MPa

So, if tensile stress of 1000 MPa is applied, fracture will not occur because the material can withstand a higher stress of 1147 MPa before it fractures. So option B is correct.

8 0
2 years ago
A center-point bending test was performed on a 2 in. x d in. wood lumber according to ASTM D198 procedure with a span of 4 ft an
Zigmanuir [339]

Answer:

3.03 INCHES

Explanation:

According to ASTM D198 ;

Modulus of rupture = ( M / I ) * y  ----- ( 1 )

M ( bending moment ) = R * length of span / 2

                                     = (120 * 10^3 ) * 48 / 2 = 288 * 10^4 Ib-in

I ( moment of inertia ) = bd^3 / 12

                                    = ( 2 )*( d )^3  / 12 =  2d^3 / 12

b = 2 in ,  d = ?

length of span = 4 * 12 = 48 inches

R = P  / 2 =  240 * 10^3 / 2 =   120 * 10^3 Ib

y ( centroid distance ) = d / 2  inches

back to equation ( 1 )

( M / I ) * y

940.3 ksi = ( 288 * 10^4 / 2d^3 / 12 ) * d / 2

                = ( 288 * 10^4 * 12 ) / 2d^3 )  * d / 2

940300  = 34560000* d / 4d^3

4d^3 ( 940300 ) = 34560000 d  ( divide both sides with d )

4d^2 = 34560000 / 940300

d^2 = 9.188   ∴ Value of d ≈ 3.03 in

8 0
2 years ago
Other questions:
  • 5. A typical paper clip weighs 0.59 g and consists of BCC iron. Calculate (a) the number of
    5·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
  • Air is compressed adiabatically from p1 1 bar, T1 300 K to p2 15 bar, v2 0.1227 m3 /kg. The air is then cooled at constant volum
    13·1 answer
  • An uninsulated, thin-walled pipe of 100-mm diameter is used to transport water to equipment that operates outdoors and uses the
    9·1 answer
  • Add a calculated field named AccountTime that calculates the number of days each client's accounts have been open. Assume today'
    6·1 answer
  • "It is necessary to select a metal alloy for an application that requires a yield strength of at least 345 MPa (50,000 psi) whil
    10·1 answer
  • Steam at 40 bar and 500o C enters the first-stage turbine with a volumetric flow rate of 90 m3 /min. Steam exits the turbine at
    9·1 answer
  • A commercial refrigerator with refrigerant-134a as the working fluid is used to keep the refrigerated space at -30C by rejecting
    13·1 answer
  • The u velocity component of a steady, two-dimensional, incompressible flow field is u = 3 ax 2 - 2 bxy, where a and b are consta
    6·1 answer
  • Who play 1v1 lol unblocked games 76
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!