Xiang
01-17-2003, 03:59 PM
Dear sir,
(a) How to create the below program?
Write a program that produces a bill and coin breakdown for an amount of money. Initialize the amount in the float variable known as dollars and use the cents variable to keep track of the amount not yet converted to bills and coins. You will have to make use of integer arithmetic and the remainder in this program.
Variables:
dollars (float)
cents (int)
Output:
The coin breakdown for 7.73 dollars is:
Dollar bills: 7
Fifty cents: 1
Twenty cents: 1
Ten cents: 0
Five cents: 0
One cents: 3
(b) Refers to the below codes. Why the "5% Service Tax" amount can't be displayed?
#include <stdio.h>
#include <conio.h>
void main()
{
int qty_sundae;
int qty_meals;
int qty_meal;
float price_sundae = 1.05;
float price_meals = 4.50;
float price_meal = 6.10;
float amt_sundae;
float amt_meals;
float amt_meal;
float amount;
float tax;
float total;
clrscr();
printf("Enter no. of Sundae cones \t : ");
scanf("%i", &qty_sundae);
printf("Enter no. of Happy meals \t: ");
scanf("%i", &qty_meals);
printf("Enter no. of Extra value meal \t: ");
scanf("%i", &qty_meal);
printf("\nWelcome to MC Donald's\n");
printf("Your Bill,\n");
amt_sundae = qty_sundae * price_sundae;
printf("\t %i Sundae cones \t :RM %5.2f\n", qty_sundae, amt_sundae);
amt_meals = qty_meals * price_meals;
printf("\t %i Happy meals \t\t :RM %5.2f\n", qty_meals, amt_meals);
amt_meal = qty_meal * price_meal;
printf("\t %i Extra value meal \t :RM %5.2f\n\n", qty_meal, amt_meal);
amount = (amt_sundae + amt_meals + amt_meal);
tax = amount * 0.05;
printf("\t 5% Service Tax \t :RM %5.2f\n\n", tax);
total = amt_sundae + amt_meals + amt_meal + tax;
printf("Total Charges \t\t\t :RM %5.2f", total);
getch();
}
Thanks,
Xiang
(a) How to create the below program?
Write a program that produces a bill and coin breakdown for an amount of money. Initialize the amount in the float variable known as dollars and use the cents variable to keep track of the amount not yet converted to bills and coins. You will have to make use of integer arithmetic and the remainder in this program.
Variables:
dollars (float)
cents (int)
Output:
The coin breakdown for 7.73 dollars is:
Dollar bills: 7
Fifty cents: 1
Twenty cents: 1
Ten cents: 0
Five cents: 0
One cents: 3
(b) Refers to the below codes. Why the "5% Service Tax" amount can't be displayed?
#include <stdio.h>
#include <conio.h>
void main()
{
int qty_sundae;
int qty_meals;
int qty_meal;
float price_sundae = 1.05;
float price_meals = 4.50;
float price_meal = 6.10;
float amt_sundae;
float amt_meals;
float amt_meal;
float amount;
float tax;
float total;
clrscr();
printf("Enter no. of Sundae cones \t : ");
scanf("%i", &qty_sundae);
printf("Enter no. of Happy meals \t: ");
scanf("%i", &qty_meals);
printf("Enter no. of Extra value meal \t: ");
scanf("%i", &qty_meal);
printf("\nWelcome to MC Donald's\n");
printf("Your Bill,\n");
amt_sundae = qty_sundae * price_sundae;
printf("\t %i Sundae cones \t :RM %5.2f\n", qty_sundae, amt_sundae);
amt_meals = qty_meals * price_meals;
printf("\t %i Happy meals \t\t :RM %5.2f\n", qty_meals, amt_meals);
amt_meal = qty_meal * price_meal;
printf("\t %i Extra value meal \t :RM %5.2f\n\n", qty_meal, amt_meal);
amount = (amt_sundae + amt_meals + amt_meal);
tax = amount * 0.05;
printf("\t 5% Service Tax \t :RM %5.2f\n\n", tax);
total = amt_sundae + amt_meals + amt_meal + tax;
printf("Total Charges \t\t\t :RM %5.2f", total);
getch();
}
Thanks,
Xiang