-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaxLoop.c
More file actions
46 lines (37 loc) · 1.09 KB
/
Copy pathtaxLoop.c
File metadata and controls
46 lines (37 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<stdio.h> //input and output
int main()
{
//declare variables
char initial;
char lastname[25];
double itemPrice;
double taxRate = .07;
double itemTax, total;
char again = 'y';//loop
//ask for the initial
printf("\nEnter your first initial: ");
//get the initial
scanf(" %c", &initial);
//ask for the last name
printf("\nEnter your last name: ");
//get the last name
scanf(" %s", lastname);
while (again == 'y')//test
{
//ask for the price
printf("\nEnter the item price: ");
//get the price
scanf("%lf", &itemPrice);
//calculate the tax
itemTax = itemPrice * taxRate;
//calculate the total
total = itemPrice + itemTax;
//print the results
printf("\nThe new total is %.2f", total);
printf("\nHave a nice day %c. %s thanks the tax was %.2f\n\n", initial, lastname, itemTax);
printf("would you like to calculate more tax (y or no)?");
scanf(" %c", &again);//update
}//end of the while loop
printf("\nGoodbye!");
return 0;
}