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
mart [117]
3 years ago
6

Write a program with total change amount as an integer input that outputs the change using the fewest coins, one coin type per l

ine. The coin types are dollars, quarters, dimes, nickels, and pennies. Use singular and plural coin names as appropriate, like 1 penny vs. 2 pennies.
Ex: If the input is:

0
or less, output:

no change
Ex: If the input is:

45
the output is:

1 quarter
2 dimes
Your program must define and call the following method. Positions 0-4 of coinVals should contain the number of dollars, quarters, dimes, nickels, and pennies, respectively.
public static void exactChange(int userTotal, int[] coinVals)
Computers and Technology
1 answer:
sweet [91]3 years ago
7 0

Answer:

#include<stdio.h>

#define DOLLAR 100

#define QUARTER 25

#define DIME 10

#define NICKEL 5

#define PENNY 1

void calculatedChange(int userAmount,int coinValues[])

{

if (userAmount >=100)

{

coinValues[0]=userAmount/DOLLAR;

userAmount=userAmount-(100*coinValues[0]);

}

if (userAmount >=25)

{

coinValues[1]=userAmount/QUARTER;

userAmount=userAmount-(25*coinValues[1] );  

}

if (userAmount >=10)

{

coinValues[2]=userAmount/DIME;

userAmount=userAmount-(10*coinValues[2]);

}

if (userAmount >=5)

{  

coinValues[3]=userAmount/NICKEL;

userAmount=userAmount-(5*coinValues[3]);

}

if (userAmount >=1)

{

coinValues[4]=userAmount/PENNY;

userAmount=userAmount-coinValues[4];

}

}

int main() {

int amount;

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

scanf("%d",&amount);

if(amount<1)

{

printf("No change..!");

}

else

{

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

calculatedChange(amount,coinValues);

if (coinValues[0]>0)

{

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

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

}

if (coinValues[1]>0)

{

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

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

}

if (coinValues[2]>0)

{

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

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

}

if (coinValues[3]>0)

{

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

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

}

if (coinValues[4]>0)

{

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

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

else printf("y");

}

}

}

Explanation:

  • Create a calculatedChange method for calculating userAmount.  
  • Use conditional statements to check dollars , quarters , dimes , nickels  and penny.
  • Inside the main method , validate the input  and then  print dollars , dimes , nickels after checking them.

You might be interested in
(ANSWER!)
andreev551 [17]

Answer:

it doesn't? maybe it helps by resetting it but other than that I don't think It does anything

4 0
3 years ago
Read 2 more answers
What is better for the sd card use as portable storage or use as internal storage?
Sever21 [200]
It depends on what you’d need it for.

> Portable Storage <
- Good for traveling.
- Good for porting stuff from a device to another device.

> Internal Storage <
- Better if you are using it for one device.
- Increase device storage.
5 0
3 years ago
What is an effective way to record change management? (5 points)
yanalaym [24]

Answer:

Detailed Notes

Explanation:

I took the 2.04 quiz

3 0
4 years ago
You will locate a presentation online that focuses on your field (for example you might choose a TED talk focused on your field)
Bogdan [553]

Answer:

presentation: "How to stop screwing yourself over" A ted talk by  Mel, an American television host. She constructively used  presentation skills such as clear verbal communication, humor, story telling  and of course, good preparation and research to present in the video, the video has more than 22 million views.

Explanation:

verbal communication: She communicated in a clear and concise language to pass her message across to the audience. This  is a vital skill for a good presentation.

Humor: She was able to use humor to lighting the presetation atmosphere without derailing from the main point. Effective use of humor will increase audience attention during the presentation.

story telling: Everybody loves story, when stories that are related to the main point of the presentation are shared, it will instill the main of point of the presentation in the mind of the audience.

Good preparation and research: Adequate preparation is key to the success of any presentation. It allows the speaker to understand his or her audience before the actual presentation as well as get all need resources for the presentation.

8 0
4 years ago
Help FAST PLS in complete sentences discuss the process used to determine your credit score. Do you think it is fair? Why or why
svlad2 [7]

Answer:

A fair credit score just means that the credit reference agencies think you're doing an okay job of managing your credit history. ... This means lenders could reject you for some of the best credit cards or loans

5 0
3 years ago
Other questions:
  • Which does an icon on the desktop signify?
    12·1 answer
  • You work for a large company. You need to implement a backup solution for your company that will allow you to perform multiple b
    11·1 answer
  • Design a hierarchy c hart or flowchart for a program that calculates the current balance in a savin gs account. The program must
    8·1 answer
  • Which button do you click to add up a series of numbers
    10·1 answer
  • Write is an I.P.O cycle? Describe with figure​
    5·1 answer
  • 13) When developing film, how do you dispose of fixer as opposed to developer?
    10·1 answer
  • What are the benefits of computer literacy?
    10·1 answer
  • Would my phone still work if I snapped it in half?
    8·2 answers
  • Is y0utube an example of unsupervised learning or supervised learning?
    13·1 answer
  • Write a program that first reads a list of 5 integers from input. Then, read another value from the input, and output all intege
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!