Question: Existing Code::: #define _CRT_SECURE_NO_WARNINGS #include int round_off(int n) { if (n % 10 >= 5) { n = n / 10 + 1; } else



Existing Code::: #define _CRT_SECURE_NO_WARNINGS #include
int round_off(int n) { if (n % 10 >= 5) { n = n / 10 + 1; } else { n = n / 10; } return n; } int main(void) { int TAX = 13; const char patSize = 'S'; double small_shirt, medium_shirt , large_shirt; int shirtamount; int subtotal, taxes, total;
printf("Set Shirt Prices "); printf("================ "); printf("Enter the price for a SMALL shirt: $"); scanf("%lf", &small_shirt); printf("Enter the price for a MEDIUM shirt: $"); scanf("%lf", &medium_shirt); printf("Enter the price for a LARGE shirt: $"); scanf("%lf", &large_shirt); printf(" ");
int smallint = 1000 * small_shirt; int mediumint = 1000 * medium_shirt; int largeint = 1000 * large_shirt;
smallint = round_off(smallint); mediumint = round_off(mediumint); largeint = round_off(largeint); printf("Shirt Store Price List "); printf("====================== "); printf("SMALL : $%d.%d ", smallint / 100,smallint % 100); printf("MEDIUM : $%d.%d ", mediumint / 100, mediumint % 100); printf("LARGE : $%d.%d ", largeint / 100, largeint % 100); printf(" Patty's shirt size is 'S' "); printf("Number of shirts Patty is buying: "); scanf("%d", &shirtamount); subtotal = smallint * shirtamount; taxes = subtotal * TAX; if (taxes % 100 >= 50) { taxes = taxes / 100 + 1; } else { taxes = taxes / 100; } total = subtotal + taxes; printf(" "); printf("Patty's shopping cart... "); printf("Contains : %d shirts ", shirtamount); printf("Sub-total: $%d.%d00 ", subtotal /100, (subtotal % 100)); printf("Taxes : $%d.%d00 ", taxes /100, (taxes %100)); printf("Total : $%d.%d00 ", total / 100, (total %100));
return 0; }
2. Carefully review the "Part-2 Output Example" (next section) to see how the program is expected to work 3. You will need to modify the code as required to produce a solution to work as demonstrated in the sample output. 4. Displaying the sales data in a tabular format requires the application of some slightly more advanced formatting features (you will learn more about this later in the semester). For now, you can use the first data line below to get you going (copy/paste into your code), and complete the printf statement accordingly: printf("Patty % -4c %5.21f %3d %9.41f %9.41f %9.41f "U... Similarly, the totals row for the above table also requires some more advanced formatting. Use the following printf statement and complete it accordingly: printf("%33.41f %9.41f %9.41f ", ... In a tabular format, show how the daily total retail sales would be broken down by coin denominations if it were to be converted to only coins (start from the largest denomination working down to the smallest). To accomplish this, you will need to apply integer division (/) to obtain the number of coins for a given denomination, followed by an application of the modulus operator (%) to obtain the new remaining amount (to be used in the next coin calculation) Note The first table is based on the sub-total and excludes taxes The second table is based on the total and includes taxes . . 6. The first data row shows only the starting balance, followed by the coin denominations in the subsequent rows. Use the partially formed printf statements below which give you a hint at how the first two (2) rows can be formatted (you will need to complete the statements accordingly): printf("%22.41f ", printf("Toonies %30 %9.41f ") 7. After each table, display the calculated average cost per shirt accordingly Part-2 Output Example (Note: Use the YELLOW highlighted user-input data for submission) Set Shirt Prices Enter the price for a SMALL shirt: $17.96 Enter the price for a MEDIUM shirt: $26.96 100% Puntoonues %50 69.41T .. 7. After each table, display the calculated average cost per shirt accordingly Part-2 Output Example (Note: Use the YELLOW highlighted user-input data for submission) Set Shirt Prices Enter the price for a SMALL shirt: $17.96 Enter the price for a MEDIUM shirt: $26.96 Enter the price for a LARGE shirt: $35.97 Shirt Store Price List EEEE SMALL $17.96 MEDIUM $26.96 LARGE $35.97 Patty's shirt size is 'S'. Number of shirts Patty is buying: 6 Tommy's shirt size is I'll Number of shirts Tommy is buying: 3 Sally's shirt size is 'M Number of shirts Sally is buying: 4 Customer Size Price Qty Sub-Total Tax Total Patty Sally Tommy S M L 17.96 26.96 35.97 6 107.7600 4 107.8400 3 107.9100 14.0100 121.7700 14.0200 121.8600 14:0300 121.9400 323.5100 42.0600 365.5700 Daily retail sales represented by coins === Sales EXCLUDING tax Coin Qty Balance 161 Toonies Loonies 323.5100 1.5100 0.5100 1 E C Number of shirts Patty is buying: 6 Tommy's shirt size is 'L' Number of shirts Tommy is buying: 3 Sally's shirt size is 'M' Number of shirts Sally is buying: 4 Customer Size Price Qty Sub-Total Tax Total Patty Sally Tommy S M L 17.96 26.96 35.97 6 107.7600 4 107.8400 3 107.9100 14.0100 14.0200 14.0300 121.7700 121.8600 121.9400 323.5100 42.0600 365.5700 Daily retail sales represented by coins SEE Sales EXCLUDING tax Coin Qty Balance Toonies 161 Loonies 1 Quarters 2 Dimes 0 Nickels Pennies 1 323.5100 1.5100 0.5100 0.0100 0.0100 0.0100 0.0000 Average cost/shirt: $24.8854 Sales INCLUDING tax Coin Qty Balance Toonies Loonies Quarters Dimes Nickels Pennies 182 1 2. 0 1 2 365.5700 1.5700 0.5700 0.0700 0.0700 0.0200 0.0000 Average cost/shirt: $28.1208
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
