We were asked to write a dollar converter program that accepts a dollar value and convert to its equivalent value in quarters, dimes, nickles and cents.
and this is as far as I've come to realizing the program... and this is just the base.... we need to convert it using the mod(%) but I have no idea how to...
Our professor gave us the value of the dollars... (it's because we're not in America or anything)
1 dollar = 100 cents
1 quarter = 25 cents
1 dime = 10 cents
1 nickle = 5 cents
Code:
#include<stdio.h>
#include<conio.h>
int main()
{
float ItemPrice, total, cash, change;
int quantity;
printf("\nAling Puring's Store v.3\n");
printf("\nEnter item price: ");
scanf("%f", &ItemPrice);
printf("\nEnter quantity: ");
scanf("%d", &quantity);
total=ItemPrice*quantity;
printf("\nTotal is: %.2f", total);
printf("\n\n******************************\n");
printf("\nCash is: ");
scanf("%f", &cash);
change=cash-total;
printf("\nChange is: %.2f", change);
getch();
return 0;
}
I ABSOLUTELY HAVE NO IDEA ON HOW TO USE A modulus(%)... and that's the clue our professor gave us