Hello,
I have two questions with the code i've written. (Hopefully this will make sense as well as the code i've written.)This is my first experience with C programming and recently received a programming problem. "A grocery store is selling oranges for 9 cents a piece or one dollar per dozen." In the code i've written, the program multiplies the 9 * any number I input. My problem is I don't know how to make the program show that when i input 12 oranges, it will come to one dollar. I get 1.08 and i've tried different methods, but i'm very stumped on how to make every dozen 12, 24, 36, etc. become $1,2,3 instead of $1.08, 2.16, etc.
Also how can i add a decimal to the amount in the correct slots for dollars and cents like
$4.15 instead of $415 or $.36 instead of $36. Do i use a floater for that? I would really appreciate anyone giving me some pointers on this problem. Thank you....
void function (int single_orange, int total_oranges);
int main(void)
{
int single_orange, total_oranges;
single_orange = 9;
printf(" The price of a single orange is 9 cents \n");
printf(" The price of a dozen oranges is 1 dollar \n");
printf( "Enter the number of oranges you would like to purchase and press enter: ");
scanf( "%d", &total_oranges );
printf( "%d * %d \n", single_orange, total_oranges);
printf("Your total comes to: $%d \n", single_orange * total_oranges);
return 0;
}