Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE WRITE THE C CODE FOR THIS LOGIC IN C Part-2 Output Example (Note: Use the YELLOW highlighted user-input data for submission) Set Shirt Prices

PLEASE WRITE THE C CODE FOR THIS LOGIC IN C

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

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions

Question

Explain the causes of indiscipline.

Answered: 1 week ago