atm code in C

here is the code for an atw withdraw only machine in C.

Page 1 of 1

5 Replies - 1958 Views - Last Post: 13 November 2010 - 02:34 PM Rate Topic: -----

#1 artgnz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 13-November 10

atm code in C

Posted 13 November 2010 - 01:33 AM

#include<stdio.h>
#include<math.h>
//ART
 
#define TOTAL_FIFTY 50
#define TOTAL_TWENTY 20
#define TOTAL_TEN 10

int withdraw;
int  total_fifty;
int  total_twenty;
int  total_ten;
int  no_fifties;
int  no_twenties;
int  no_tens;
int fifties;
int twenties;
int tens;
 int main (void)
{
 
  do {
                printf("Please enter amount of withdraw in multiples of $10.00\n$");
               scanf("%d", &withdraw);
          } while(  (withdraw%10)!=0  );

 if (withdraw>=0){
  
 printf("\nYour amount of $%d.00\n\n",withdraw);
 
 
 if (withdraw>=0)                                                   
  fifties=withdraw/TOTAL_FIFTY;                   
  no_fifties=withdraw-(fifties*TOTAL_FIFTY);
     
 if (no_fifties>=0)
  twenties=no_fifties/TOTAL_TWENTY;
  no_twenties=withdraw-(fifties*TOTAL_FIFTY)-(twenties*TOTAL_TWENTY);
     
 if (no_twenties>=0)
  tens=no_twenties/TOTAL_TEN;
  no_tens=withdraw-(fifties*TOTAL_FIFTY)-(twenties*TOTAL_TWENTY)-(tens*TOTAL_TEN);
     
 printf("Will be destributed in \n %d fifties, \n %d twenties, \n %d tens as change.\n\n", fifties,twenties,tens);
}
 
return (0) ;  
}


MOD EDIT: When posting code...USE CODE TAGS!!!

:code:

This post has been edited by JackOfAllTrades: 13 November 2010 - 04:53 AM


Is This A Good Question/Topic? 0
  • +

Replies To: atm code in C

#2 Alex6788  Icon User is offline

  • kitties == adorable


Reputation: 144
  • View blog
  • Posts: 1,667
  • Joined: 15-July 10

Re: atm code in C

Posted 13 November 2010 - 01:39 AM

What's wrong?, all you did was post some code, are you getting any errors? If you are copy and paste the errors you are getting.

Also please post code in code tags :code:

EDIT: I'm pretty sure that return 0; shouldn't have those ( ) around the zero. Also i think this is just a dump and run.

This post has been edited by Alex6788: 13 November 2010 - 01:41 AM

Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6245
  • View blog
  • Posts: 24,013
  • Joined: 23-August 08

Re: atm code in C

Posted 13 November 2010 - 04:55 AM

Alex6788, the parentheses around the value in the return statement are OK. Some use them, some don't, but it's just fine and dandy to have them. It's strictly a stylistic thing.
Was This Post Helpful? 1
  • +
  • -

#4 Alex6788  Icon User is offline

  • kitties == adorable


Reputation: 144
  • View blog
  • Posts: 1,667
  • Joined: 15-July 10

Re: atm code in C

Posted 13 November 2010 - 05:01 AM

View PostJackOfAllTrades, on 13 November 2010 - 05:55 AM, said:

Alex6788, the parentheses around the value in the return statement are OK. Some use them, some don't, but it's just fine and dandy to have them. It's strictly a stylistic thing.

Okay, thanks.
Was This Post Helpful? 0
  • +
  • -

#5 Guest_ART*


Reputation:

Re: atm code in C

Posted 13 November 2010 - 01:05 PM

View PostAlex6788, on 13 November 2010 - 12:39 AM, said:

What's wrong?, all you did was post some code, are you getting any errors? If you are copy and paste the errors you are getting.

Also please post code in code tags :code:

EDIT: I'm pretty sure that return 0; shouldn't have those ( ) around the zero. Also i think this is just a dump and run.


I'm trying to get the input of the user to be in decimal .00
That's all I need
Was This Post Helpful? 0

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6245
  • View blog
  • Posts: 24,013
  • Joined: 23-August 08

Re: atm code in C

Posted 13 November 2010 - 02:34 PM

Use a double rather than an integer?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1