How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask ATLPROG Your Own Question

ATLPROG
ATLPROG, Computer Software Engineer
Category: Programming
Satisfied Customers: 8542
Experience:  MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
Type Your Programming Question Here...
ATLPROG is online now
A new question is answered every 9 seconds

I am new to C programming, and this is an assignment problem.

Resolved Question:

I am new to C programming, and this is an assignment problem. I have no idea how to accomplish this.


Call the function change() from main() three times and print out the contents of the variables quarters, dimes, nickels, and pennies after each function return.
First Call--pass in the total value $1.88 and on return print the contents of the variables.
Second Call--pass in the total value .32 and on return print the contents of the variables.
Third Call--ask for a total value input from the keyboard and on return print the contents of the variables.

Output should look like:
TOTAL VALUE ENTERED: 1.88
7 quarters
1 dime
0 nickels
3 pennies
and not:
TOTAL VALUE ENTERED: 1.88
7 quarters
18 dimes
37 nickels
188 pennies
Submitted: 11 months ago.
Category: Programming
Expert:  ATLPROG replied 11 months ago.

ATLPROG : Hi welcome. I will have this ready soon
ATLPROG :

Hello

ATLPROG :

Please confirm if you still need assistance with this

Customer:

Yes, I still need help with this. The website was having problems when I tried to submit it this morning.

Customer:

Hello?

ATLPROG :

Sorry for that..

ATLPROG :

i will have this ready soon

Customer:

I have some code that mostly works.


#include <stdio.h>



int change(float total, int *quarters, int *dimes, int *nickels, int *pennies);


void print(float total, int quarters, int dimes, int nickels, int pennies);




int main(void)


{


int quarters, dimes, nickels, pennies;


float total;






printf("This program will give the coins required for two fixed values, and one user input value.\n");






total = 1.88;


change(total, &quarters, &dimes, &nickels, &pennies); //for the first call to change, calculates for defined value of 1.88


print(total, quarters, dimes, nickels, pennies);



total = 0.32;


change(total, &quarters, &dimes, &nickels, &pennies); //for the second call, calculates for defined value of 0.32


print(total, quarters, dimes, nickels, pennies);






printf("\nPlease enter an amount of money: "); //This gets the users input for the amount to make change for.


scanf("%f", &total);






change(total, &quarters, &dimes, &nickels, &pennies); //calls the function change() to calculate for the user input





print(total, quarters, dimes, nickels, pennies); //prints the user input values for change






fflush(stdin); /* clear input area so you can pause */


printf("Press the key to exit program.");


getchar(); /* force the computer to pause until you press a key on the keyboard */




return 0;


}





int change(float total, int *quarters, int *dimes, int *nickels, int *pennies) //declares the variables for the change function




{







if( total >= 0.25 )


*quarters = (total / 0.25); //calculates the amount of quarters, and stores it into quarters


if( total >= 0.10 )


*dimes = (total - (*quarters * 0.25)) / 0.10; //calculates the amount of dimes, and stores it into dimes


if( total >= 0.05 )


*nickels = (total - (*quarters * 0.25) - (*dimes * 0.10)) / 0.05; //calculates the amount of nickels, and stores it into nickels


if( total >= 0.01 )


*pennies = (total - (*quarters * 0.25) - (*dimes * 0.10) - (*nickels * 0.05)) / 0.01 + .005; //calculates the amount of pennies, and stores it into pennies








return 0;


}



void print(float total, int quarters, int dimes, int nickels, int pennies)


{


printf("\nTOTAL VALUE ENTERED: $%.2f", total);


printf("\n%3d quarters\n", quarters);


printf("\n%3d dimes\n", dimes);


printf("\n%3d nickels\n", nickels);


printf("\n%3d pennies\n", pennies);

Customer:

I have some code that mostly works. The only thing is that it doesn't work for values below 0.32 What am I doing wrong?


#include <stdio.h>



int change(float total, int *quarters, int *dimes, int *nickels, int *pennies);


void print(float total, int quarters, int dimes, int nickels, int pennies);




int main(void)


{


int quarters, dimes, nickels, pennies;


float total;






printf("This program will give the coins required for two fixed values, and one user input value.\n");






total = 1.88;


change(total, &quarters, &dimes, &nickels, &pennies); //for the first call to change, calculates for defined value of 1.88


print(total, quarters, dimes, nickels, pennies);



total = 0.32;


change(total, &quarters, &dimes, &nickels, &pennies); //for the second call, calculates for defined value of 0.32


print(total, quarters, dimes, nickels, pennies);






printf("\nPlease enter an amount of money: "); //This gets the users input for the amount to make change for.


scanf("%f", &total);






change(total, &quarters, &dimes, &nickels, &pennies); //calls the function change() to calculate for the user input





print(total, quarters, dimes, nickels, pennies); //prints the user input values for change






fflush(stdin); /* clear input area so you can pause */


printf("Press the key to exit program.");


getchar(); /* force the computer to pause until you press a key on the keyboard */




return 0;


}





int change(float total, int *quarters, int *dimes, int *nickels, int *pennies) //declares the variables for the change function




{







if( total >= 0.25 )


*quarters = (total / 0.25); //calculates the amount of quarters, and stores it into quarters


if( total >= 0.10 )


*dimes = (total - (*quarters * 0.25)) / 0.10; //calculates the amount of dimes, and stores it into dimes


if( total >= 0.05 )


*nickels = (total - (*quarters * 0.25) - (*dimes * 0.10)) / 0.05; //calculates the amount of nickels, and stores it into nickels


if( total >= 0.01 )


*pennies = (total - (*quarters * 0.25) - (*dimes * 0.10) - (*nickels * 0.05)) / 0.01 + .005; //calculates the amount of pennies, and stores it into pennies








return 0;


}



void print(float total, int quarters, int dimes, int nickels, int pennies)


{


printf("\nTOTAL VALUE ENTERED: $%.2f", total);


printf("\n%3d quarters\n", quarters);


printf("\n%3d dimes\n", dimes);


printf("\n%3d nickels\n", nickels);


printf("\n%3d pennies\n", pennies);

Expert:  ATLPROG replied 11 months ago.
Our chat has ended, but you can still continue to ask me questions here until you are satisfied with your answer. Come back to this page to view our conversation and any other new information.

What happens now?

If you haven’t already done so, please rate your answer above. Or, you can reply to me using the box below.
Expert:  ATLPROG replied 11 months ago.
I will provide answer soon
Customer: replied 11 months ago.

You never answered my question.

Expert:  ATLPROG replied 11 months ago.
I thought i did..please download solution from
http://wikisend.com/download/130442/ChangeCoins.c

I hope i was able to assist you. If you are happy with my service please rate my service . If your are not 100% satisfied, please reply to me so that i can help you better. Please start your question with "For ATLProg only" to request me again
ATLPROG, Computer Software Engineer
Category: Programming
Satisfied Customers: 8542
Experience: MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
ATLPROG and 5 other Programming Specialists are ready to help you
Customer: replied 11 months ago.

You didn't send me the link to download it until now.

Expert:  ATLPROG replied 11 months ago.
Sorry for that..did you get it now?
Customer: replied 11 months ago.

Yes, I had to turn in my assignment without it though.

Expert:  ATLPROG replied 11 months ago.
We have website issues on that day and i thought i had posted the link but looks like it didnt post it properly back then. Sorry for that

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer New York
< Last | Next >
  • My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer New York
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
 
 
 

Meet The Experts:

 
 
 
  • ATLPROG's Avatar

    ATLPROG

    Computer Software Engineer

    Satisfied Customers:

    7463
    MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
< Last | Next >
  • http://ww2.justanswer.com/uploads/SP/spatlanta2010/2011-6-23_12450_photo.64x64.gif ATLPROG's Avatar

    ATLPROG

    Computer Software Engineer

    Satisfied Customers:

    7463
    MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Computer Software Engineer

    Satisfied Customers:

    5603
    Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.
  • http://ww2.justanswer.com/uploads/unvadim/2010-11-15_210218_avatar.jpg unvadim's Avatar

    unvadim

    Computer Software Engineer

    Satisfied Customers:

    1158
    Good knowledge of OOP principles. 3+ years of programming experience with Java and C++. Sun Certified Java Programmer 5.0.
  • http://ww2.justanswer.com/uploads/lifesaver333/2010-10-17_191349_ls.jpeg lifesaver's Avatar

    lifesaver

    Computer Software Engineer

    Satisfied Customers:

    950
    Several years of intensive programming and application development experience in various platforms.
  • http://ww2.justanswer.com/uploads/EH/ehabtutor/2012-8-2_202016_1.64x64.jpg ehabtutor's Avatar

    ehabtutor

    Computer Software Engineer

    Satisfied Customers:

    864
    Bachelor of computer science, 5+ years experience in software development, software company owner
  • http://ww2.justanswer.com/uploads/RA/rajivsharma086/2012-6-6_17128_displaypic.64x64.jpg Raj's Avatar

    Raj

    Computer Engg.

    Satisfied Customers:

    860
    BE CS, 4+ Experience in Programming and Database (ERP)
  • http://ww2.justanswer.com/uploads/eljonis/2010-01-06_130406_eljon2.jpg Eljon's Avatar

    Eljon

    Consultant

    Satisfied Customers:

    590
    11 yrs of programming (PHP, WordPress, XSL, SQL, JavaScript)