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
Which of the following are considerations in e-commerce and e-government Internet sites? Check all of the boxes that apply.
vovangra [49]

Answer:

protection of sensitive information

Explanation:

6 0
3 years ago
In linux, a(n) ____ is a data structure that stores all information (such as file permissions, ownership, and file type) about a
Galina-37 [17]
Hi,


Answer => <span>Inode


Good Lessons </span>
4 0
4 years ago
Write the lyrics toooo.. Saints. Who every gets it correct gets brainliest!<br> No copying
Orlov [11]
I'm sorry but your story isn't adding up
Think your religion is a lie to keep my mouth shut
So I won't testify the crimes you're keeping score of
Why don't you throw me to the wolves? I thought you were one
You were standing there like an angry god
Counting out my sins just to cross them off
Saying that my tongue was too loud to trust
And that my blood couldn't keep you
My dear, you're not so innocent
You're fooling Heaven's gates
So you won't have to change
You're no saint, you're no savior
Your revelations don't look nothing like the pictures
You read between the lines and don't stick to the scriptures
You only follow rules if others follow with you
That doesn't sound so holy only playing victim
You were standing there like an angry god
Counting out my sins just to cross them off
Saying that my tongue was too loud to trust
And that my blood couldn't keep you
My dear, you're not so innocent
You're fooling Heaven's gates
So you won't have to change
You're no saint, you're no savior
So keep your judgment for someone else, I've had enough
And keep your judgment for someone else, I've had enough
So keep your judgment for someone else, I've had enough
And keep your judgment for someone else, I've had enough
My dear, you're not so innocent
You're fooling Heaven's gates
So you won't have to change
You're no saint, you're no savior
6 0
3 years ago
Jason works as a Help Desk Technician for uCertify Inc. The company has a Microsoft Windows XP-based network. Jason wants to vie
WINSTONCH [101]

Answer:

ipconfig

Explanation:

ipconfig (short for <em>internet protocol configuration</em>) is a command line tool used for determining the network connection configuration of a computer. Some of these configuration information are;

i. the IP address of the computer

ii. default gateway address

iii. subnet mask

iv. Media Access Control (MAC) address.

6 0
3 years ago
Write a report on how you would analyze your organization and how you would select an appropriate security policy framework. Sea
olga nikolaevna [1]

Answer and Explanation:

We analyzed the security act in the organization by the following reason.

  • Protection of data  
  • Privacy of data  
  • Prevent the data loss in the network
  • Network security protection

Formation security platforms seem to be a set of structured policies, protocols and instructions aimed at directing a company or some other entity that uses them to secure their equipment, programs, content, data, server, computer systems, clients and customers through possible safety violations by using the company's facilities or services.

5 0
3 years ago
Other questions:
  • Which of the following statements is/are true by definition.
    5·1 answer
  • A __________ is a repository of data gathered from operational data and other sources that is designed to serve a particular com
    7·1 answer
  • Encapsulation is a form of information hiding and an important characteristic of object-oriented programming. When a programmer
    6·1 answer
  • select the correct answer from each drop-down menu. “To clean a computer screen, use ___. To clean a keyboard, use a ___.”
    7·1 answer
  • How to do the for loop in python
    12·1 answer
  • Before u can open and edit a file, you need to zip it, T/F
    12·1 answer
  • Which of the following tabs on the Ribbon contains the command to add a Quick Part to a document? A Design B Insert C View D Hom
    7·1 answer
  • When a value of one data type is automatically changed to another data type, a(n) ____________________ type coercion is said to
    7·1 answer
  • SOMEONE HELP ME!!!!!
    8·1 answer
  • What are the two different types of dns requests?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!