In: Computer Science
Write a C program that summarizes an order from a fictitious store. You must have these four lines in your program: float bike_cost, surfboard_cost; float tax_rate, tax_amount; int num_bikes, num_surfboards; float total_cost_bikes, total_cost_surfboards; float total_cost, total_amount_with_tax; You will assign your own unique values for each of the variables, except the totals which are computed. No other variables are needed in the program. For example, you will see the numbers I picked in my program in the sample output below. I used 7.5% for my tax rate. Once you create and run your program, all the following should be output from your program, except your store name and numbers will be different: Sears Bike and Board Shop order: 3 bikes at $109.95 per bike is $329.85 5 surfboards at $219.00 per surfboard is $1095.00 Order Total: $1424.85 Tax Amount: $106.86 Total Amount Due: $1531.71 Thank you for your order.
Source Code:
#include<stdio.h>
int main()
{
float bike_cost, surfboard_cost;
float tax_rate, tax_amount;
int num_bikes, num_surfboards;
float total_cost_bikes, total_cost_surfboards;
float total_cost, total_amount_with_tax;
printf("enter the bike cost and surfboard_cost in
$\n");
scanf("%f
%f",&bike_cost,&surfboard_cost);
printf("enter the number of bikes and surfboards
\n");
scanf("%d
%d",&num_bikes,&num_surfboards);
printf("enter the tax rate in %%\n");
scanf("%f",&tax_rate);
total_cost_bikes=num_bikes*bike_cost; //to calculate
total cost of bikes
total_cost_surfboards=num_surfboards*surfboard_cost;
//to calculate total cost of surfboards
total_cost=total_cost_bikes+total_cost_surfboards; //
total amount without tax is calculated
tax_amount=total_cost*tax_rate/100; // tax amount is
calculated
total_amount_with_tax=total_cost+tax_amount; //total
amount with taxt is calculated
printf("total cost of bikes is
:%0.2f$\n",total_cost_bikes);
printf("total cost of bikes is
:%0.2f$\n",total_cost_surfboards);
printf("Order Total :%0.2f$\n",total_cost);
printf("total Tax Amount is
:%0.2f$\n",tax_amount);
printf("Total Amount
Due:%0.2f$",total_amount_with_tax);
return 0;
}
Output:
enter the bike cost and surfboard_cost in $
109.95 219.00
enter the number of bikes and surfboards
3 5
enter the tax rate in %
7.5
total cost of bikes is :329.85$
total cost of bikes is :1095.00$
Order Total :1424.85$
total Tax Amount is :106.86$
Total Amount Due:1531.71$
--------------------------------
Process exited after 8.606 seconds with return value 0
Press any key to continue . . .