I'm working on a cash register program using C ++ the issue is that i'm not sure how to use the mod operator to get the remainder and figure out how many cents and bills needed ( Twenties, tens, fives, dollars, quarters, dimes , nickels, pennies)
I used a float to get the change now someone told me i should split that change value into changeindollars and changeincents, then it should be easier to get the other details. This is what i got down so far:
thanks for the help anyone.
Code:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void)
{
float amountPurchase=0.00;
float amountTendered=0.00;
float change=0.00;
int changeInDollars=0;
int changeInCents=0;
int Twenties, Tens, Fives;
printf("Welcome to the Online cash register!\n");
printf("Please enter the total amount of purchase: $");
scanf("%f", & amountPurchase);
getchar();
printf("Please enter the amount of money tendered: $");
scanf("%f",& amountTendered);
getchar();
change = amountTendered - amountPurchase;
printf("Your changes is:$ %.2f\n", change);
changeInDollars = ?
changeInCents = ?
Twenties = changeInDollars / 20;
printf("Twentie: %i\n", Twenties);
Tens = changeInDollars /10;
printf("Ten: %i\n", Tens);
Fives = changeInDollars /5;
printf("Five: %i\n", Fives);
printf("Thanks you for using the Online cash register!\n");
getchar();
return EXIT_SUCCESS;
}