Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.2lf %3d %9.4lf %9.4lf %9.4lf ",... 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.4lf %9.4lf %9.4lf ",... 5. 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.4lf ",... printf("Toonies %3d %9.4lf ", ... 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 ====================== 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 '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 S 17.96 6 107.7600 14.0100 121.7700 Sally M 26.96 4 107.8400 14.0200 121.8600 Tommy L 35.97 3 107.9100 14.0300 121.9400 -------- ---- ----- --- --------- --------- --------- 323.5100 42.0600 365.5700 Daily retail sales represented by coins ======================================= Sales EXCLUDING tax Coin Qty Balance -------- --- --------- 323.5100 Toonies 161 1.5100 Loonies 1 0.5100 Quarters 2 0.0100 Dimes 0 0.0100 Nickels 0 0.0100 Pennies 1 0.0000 Average cost/shirt: $24.8854 Sales INCLUDING tax Coin Qty Balance -------- --- --------- 365.5700 Toonies 182 1.5700 Loonies 1 0.5700 Quarters 2 0.0700 Dimes 0 0.0700 Nickels 1 0.0200 Pennies 2 0.0000 Average cost/shirt: $28.1208

Reflection (50%) Instructions Record your answer(s) to the reflection question(s) in the provided reflect.txt text file 1. Given the following C statements: double price1 = 10.10, price2 = 10.12, price3 = 10.15; int cents1 = (int)(price1 * 100); int cents2 = (int)(price2 * 100); int cents3 = (int)(price3 * 100); printf("%d 10.10 = %.15lf ", cents1, price1); printf("%d 10.12 = %.15lf ", cents2, price2); printf("%d 10.15 = %.15lf ", cents3, price3); Briefly explain why the cents2 variable doesn't properly represent the total cents of price2. 2. You had to use integer division (/) to get the number of coins and the modulus (%) operator to easily obtain the remainder amount after each coin denomination calculation. Let's assume this program needed to be modified to only determine the breakdown of paper bills ($50, $20, $10, $5). Provide the few lines of code that would be required to demonstrate how the $20 denomination would be calculated (use your solution variables in your example). 3. Displaying total cents in the format of dollars and cents (ex: 7245 to $72.45) required converting (casting) an integer to a floating-point type (along with a simple calculation). Without changing any variable data types, show three (3) different ways to accomplish the same outcome (use your solution variables in your example). If you are having problems thinking of how to approach this, think about how an expression can be promoted or narrowed in several ways based on explicit casting, coercion, and how each operand plays a role in this determination.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

What is managerial accounting

Answered: 1 week ago