Program 1
Assume a newspaper wants to display the sales in each quadrant of town.
The quadrant, number of customers, and sales are:
In the Northwest quadrant, 23 customers with sales of $ 345.00
In the Northeast quadrant, 156 customers with sales of $ 2111.11
In the Southwest quadrant, 9 customers with sales of $ 120.80
In the Southeast quadrant, 222 customers with sales of $3030.35
Requirements :
Newspaper: Daily Herald
Month: June 2014
#===================================#
Town Number of Month's
Quadrant Customers Sales
#===================================#
Northwest 23 345.00
Northeast 156 2111.11
Southwest 9 120.80
Southeast 222 3030.35
#===================================#
Write a program, using output manipulators, to produce the following output exactly:
Output Notes:
• The Newspaper and Month values are aligned on the right.
• The 'T' of the "Town" column label appears in column 6 of console screen
(i.e. there are 5 spaces before the word "Town").
• The Number of Customers and Month's Sales values are rounded to 2 decimal places
and are aligned on the right.
Do not convert the Number of Customers and Sales values in the code to strings (e.g. "23" or
"345.00"). They should both be coded in the output statements as numbers (e.g. 23 and 345.00).
Minimally, you must use the setfill output manipulator to create and format the dividing lines, and
you must use the setw and setprecision output manipulators to format the numeric output in the
table.
No variables or constants should be used in this program.
Program #2
Write a program that computes a bill for newspaper delivery for a charge period (weekly, monthly,
annually, etc).
The charge for the daily newspaper is 52 cents. The charge for a Sunday newspaper is 75 cents.
Customers may also tip a percentage of the monthly bill.
Since the number of days in a charge period varies, the program will need to do some calculations.
Prompt the user for the number of days in the charge period and a tip percentage. Use these figures
to calculate the total bill.
For every 7 days, charge for 6 daily papers and 1 Sunday paper. Remaining days will be charged at
the daily rate. (Hint: Use the division operator (/) to determine the number of full weeks/Sundays,
and use the modulus operator (%) to determine the number of remaining days over the full weeks).
Requirements:
The program must:
• Define an integer constant that holds the number of daily papers in one week.
• Define two floating point constants that will hold:
o The cost of a daily newpaper
o The cost of a Sunday newspaper
• Define a string constant for the customer's name - use YOUR name
(e.g., "Samantha Washington")
• Define two character variables for the quadrant of town being served
o One will hold a character representing either the north or south side of town
- Initialize this value to 'S' for south, when you define it
o One will hold a character representing the east or west side of town
- Initialize this value to 'W' for west, when you define it
• Define an integer variable to store the number of days in the charge period
(read from the user)
• Define a floating point variable to store the tip rate (read from the user)
• Define five floating point variables to store parts of the total cost, the subtotal and the total.
o The cost of all Sunday papers
o The cost of all daily papers
o The newspaper subtotal
o The tip charge
o The total bill
• Display a program description, followed a prompts and input statement to read number of
days in the charge period from the user.
Sample Input
• Calculate the newspaper costs and then the tip.
• Add all of the above together to determine the total.
• Add any other variable definitions or calculation statements you think are needed to perform
the task
• Display a few blank lines to separate the input from the output. Then use output
statements to display the results to the console, in the following format:
NOTES:
o The dollar figures in the totals column should all line up, aligned right, on the
decimal point.
o If the customer enters 0% for the tip, the tip displayed will be 0.00.
Documentation
1) For each program, be sure to include top of program comments
(as specified in course Content section 1.8) that include:
Your name, the course, and the assignment number
What the Program Does including:
What is Input
Processing/Calculations Performed
What is Output
Customer: Samantha Washington
Location: SW quadrant
Days in Period: 30
Tip Rate: 4.2%
Cost for daily papers 13.52
Cost for Sunday papers 3.00
---------
Newspaper Total 16.52
Tip for Carrier 0.69
---------
Total Billed to Customer 17.21
Newspaper Billing Program
Enter number of days in the charge period: 30
Enter tip percentage (e.g. 5.5 for 5.5% or 0 for none):
2) Clarifying comments beside constants and variable declarations
3) Inline clarifying documentation, as needed