Carpet costs include the cost of the carpet


The local discount carpet store would like help calculating customer bills for carpet. 

Carpet costs include the cost of the carpet and the pad. A customer may also choose to have furniture moved out of and back into the space and to have the old carpet removed and hauled away when the new carpet is installed. 

Write a program to help compute the bill for one customer. 

Specifications: 
• Carpet and pad costs are based upon the number of square feet of carpet needed. Rooms are measured in inches. There are 12 inches to a foot, and 3 feet in a yard, and 9 square feet in 1 square yard. 
• All carpet in the store runs $25.94 per square yard. 
• Two pad types are available: 
o The standard pad costs $5.25 per square yard. 
o The premium pad costs $6.73 per square yard. 
• By default, when the customer has new carpet installed, the old carpet will be removed and hauled away. If a customer chooses to do this part himself, they will be given a 6.5% discount on the cost of the carpet only. 
• If the customer wants the furniture moved, there is a $26.66 charge per room. 

Implementation Requirements: 
Data Storage: 
• The program must use constants for ALL fixed values (therefore, there should be no hardcoded numbers in your program). 
• The program shall use descriptive names for all constants and variables, and follow the naming conventions in the Coding Standards. 
• The program shall use double type constants and variables for all floating point values (not float). 
The user will enter the following input: 
• The length and width of the space 
• The type of pad to install 
o Read the pad type as a single character ( 's'/'S' for standard or 'p'/'P' for premium). 
The user may enter the character in either upper or lowercase. Use a pre-defined function from the cctype library to insure that the character is stored in uppercase when your code uses the value later to decide what to charge and what to display. 
• Whether the customer wants to the carpet store to remove the old carpet o Read from the user ('s'/'S' for store removal, 'c'/'C' for customer removal) and store as a single character 
o After reading the input character, the program will assign a value to a Boolean variable called giveDiscount (true for customers who remove their own carpet, false for customers who will have the store remove the carpet) and use only that Boolean in later processing, when testing the value to decide whether to give a discount. 
o The user may enter the character in either upper or lowercase. The program must use a logical operator to test for both upper and lowercase when deciding whether to store true or false in the Boolean variable (i.e. Use a logical operator instead of using a cctype predefined function). • Whether the customer wants the furniture moved o Read answer from the user as a string: "yes" or "no" 
o The prompt should indicate that the string must be entered in all lowercase letters. 
o If the user enters "yes", also prompt for the number of rooms, and calculate the 
total furniture moving charge. 
NOTE: No error checking of the user input is required. You may assume that the user entered a valid answer for each question, and assume also valid input for test cases. 

Required User-Defined Function: 
• Create separate a user-defined function to calculate the number of square yards. 
• The function will take two input parameters: the length and width of the space. 
• The function will return the number of square yards of carpet needed for the space. 

Sample Input 1: 
Carpet Purchase Bill Calculation Program 

Enter space length and width in inches, 
separated by a space: 222.2 256.1 

Pad type: standard or premium (S/P)? s 
Who will remove the old carpet: store or customer (S/C): c 

Store to move furniture? (yes or no, all lowercase): yes 
Number of rooms? 3 

Sample Output 1: 
Notes on Sample Output: 
a) Display a couple of blank lines after all input has been entered and before the carpet order details and bill are displayed. 
b) All order details and bill amounts should line up on the right. 
c) The pad type should be displayed in a word (not a character). 
d) Only display the discount if the customer removes the old carpet. If the customer lets the store remove the old carpet and there is no discount, then the discount amount, the separating line, and the subtotal will not be displayed at all. 
e) If customer does not want furniture moved (i.e. they will move it before installation), then there will be no moving cost, and the moving cost line should not be displayed at all. 

Sample Input and Output 2: 
CARPET ORDER DETAILS 
Square Yards Ordered: 43.91 
Pad Type: standard 


CARPET BILL 
Carpet Cost: 1138.99 
minus Discount: 74.03 
--------- 
Subtotal: 1064.95 
plus Pad Cost: 230.52 
plus Moving Cost: 79.98 
--------- 
Bill Total: 1375.45 
Carpet Purchase Bill Calculation Program 

Enter space length and width in inches, 
separated by a space: 120 121.5 

Pad type: standard or premium (S/P)? P 
Who will remove the old carpet: store or customer (S/C): S 

Store to move furniture? (yes or no, all lowercase): no 


CARPET ORDER DETAILS 
Square Yards Ordered: 11.25 
Pad Type: premium 


CARPET BILL 
Carpet Cost: 291.82 
plus Pad Cost: 75.71 
--------- 
Bill Total: 367.5

Program #2 

The IRS may allow a deduction for Student Loan Interest paid. A taxpayer can claim the deduction if his/her income falls below specified limits and the filing status is any filing status except married filing separately. This deduction may decrease the amount of income subject to tax by up to $2,500. 

You will write a program that carries out the logic of the IRS worksheet to determine how much interest may be deducted. 

Sample IRS instructions for each line of the worksheet (modified slightly from actual worksheet) This worksheet may be used by any taxpayer who is not married filing separately. 
Line 1 Enter the total interest paid for the year on qualified student loans on line 1. 
(worksheet amount will be limited to a maximum of $2500, even if a large amount was paid) 
Line 2 Enter Total Income amount from Form 1040, line 22 on line 2. 
Line 3 Enter Adjustments to Income from Form 1040, lines 23 through 32 on line 3. 
Line 4 Subtract line 3 from line 2 and enter the result on line 4. 
Line 5 Determine the Income Limit amount for your filing status from the list below and 
enter it on line 5: 
Single, Head of household, Qualifying Widow(er) - $ 60,000 
Married filing jointly - $ 120,000 
Line 6 Is the amount on line 4 more than the amount on line 5? 
No. Skip lines 6 through 8. Enter the amount from line 1 on line 9. 
Yes. Subtract line 5 from line 4 and enter the Amount Over on line 6. 
Line 7 Divide line 6 by $15,000 (or $30,000 if married filing jointly) to determine a 
percentage that will be excluded from the deduction. 
Enter the result rounded to three places on line 7. 
If the result is 1.000 or more, enter 1.000 on line 7. 
Line 8 Multiply line 1 by line 7 and enter the result on line 8. 
Line 9 Subtract line 8 by line 1 and enter result on line 9. 
The line 9 amount is your Student Loan Interest Deduction. 
Enter the line 9 results on Form 1040, line 33. 


(see next page for more details) 
The user inputs will be: 
• Filing status (one of the following) 
1. Single, 
2. Married, Filing Jointly, 
3. Head of Household, 
4. Qualifying Widow, 
5. Married, Filing Separately. 
• Amount of Interest paid on Student Loans 
• Total Income (1040, line 22) 
• Total Adjustments (1040, lines 23 - 32) 
Sample Input 2a 

When the user enters 1, 2, 3 or 4 (but not 5), you will also need to read the rest of the input. 

Sample Input 2b 
NOTE: No error checking of any user input is required. You may assume that the user entered a 
valid answer for each question. 

Program Logic Summary 
• Read the filing status of the taxpayer. 
• Perform a test to determine if the taxpayer should continue, or if the program should exit. 
o If the taxpayer's filing status is married filing separately, there will be no 
deduction. Display a message saying so (see Sample 2 Output below) and pause. 
Then return from main with exit code of 5, to indicate that the taxpayer's filing 
status was 5. 
return 5; 
Student Loan Interest Deduction Worksheet Program 

1 - Single 
2 - Married, Filing Jointly 
3 - Head of Household 
4 - Qualifying Widow(er) 
5 - Married, Filing Separately 
Enter your filing status from above (1-5): 2 
Enter Interest Paid on Student Loans: 2222 

Enter Total Income (from 1040 line 38): 145000 

Enter Adjustments to Income (from 1040, lines 23-32): 2500 
o If the program did not exit, continue. 
• Read and store the input for line 1 from the user. 
• Adjust amount stored for line 1, if it is higher than allowed. 
• Read and store the inputs for lines 2 and 3 from the user. 
• Perform the necessary calculation for line 4 and store the result. 
• Determine the line 5 income limit that applies for the filing status entered, and store the 
result. 
HINT: Store the filing status description in words into a string variable at the same time. 
• Display the Worksheet title and the first 5 lines (1 - 5) of the worksheet. 
• Perform the line 6 test to determine if the program should skip some lines. 
o If line 4 is not more than line 5, store the amount from line 1 into the variable for 
line 9, and skip the logic for lines 6 through 9 below. 
Otherwise 
o Perform the necessary calculation for line 6 and store the result. 
o Call a user-defined function to find the amount for line 7 and store the value 
returned. 
The user-defined function will have two input arguments: 
the line 6 amount and the filing status 
The function will use the filing status to determine which amount to divide by, 
and will divide to find the value for line 7. 
The function will adjust the value if it is too high. 
The function will return the floating point result. 
Examples: 
o Input arguments of line 6 = 15555 and filing status 1 
would return 1.000 
o Input arguments of line 6 = 25555 and filing status 2 
would return 0.8518333... 
No other computations should be performed within this function. 
o Perform the necessary calculation for line 8 and store the result. 
o Display lines 6 through 8 of the worksheet, making sure that line 7 is displayed to 
3 decimal places (see Sample 1 Output below). 
o Perform necessary calculation for line 9 and store the result. 
• Whether lines were skipped or not, display line 9 and instructions on where to enter the 
results. 

Exit Codes 

In your previous programs, you have seen the line: 
return 0; 
used to return from the main function. 

When the code in the main function finished running, the program is done executing. So when a 
program returns from within main, it finishes the execution of main, and ends the program. 
(Note that returning from any function other than main does not end the program.) 

So the return line in main causes the program to end execution, and returns an "exit code" of 0 
(zero) to the operating system. On most operating systems, an exit code of zero indicates that the 
program ran successfully. But a program can also return from main using some other integer 
value as the exit code, to indicate that the program exited for some specific reason. 

For example, this line in main: 
return 99; 
will cause the program to exit and pass back an exit code of 99 to the operating system (note that 
it is up to the programmer to decide what each exit code means). See online Content section 3.8 
for more details. 

In this program you will use an exit code to indicate an early exit, if the filing status is invalid. 

• If the program exits before line 1, only a message will be displayed as output, and the 
program will return an exit code of 5 in the middle of the program: 
return 5; 
• Depending on the results of line 6, the program will either display: 
o The worksheet title and lines 1 - 5 and 9 OR 
o The worksheet title and lines 1 - 9 
along with the message about where to enter the results. 
• The output should adhere to the formatting shown in the samples below 
(decimals in dollar values should line up as shown). 
• If the program does not exit before line 1, then the program will return at the end of the 
main function with an exit code of 0 (to indicate the successful completion of the entire 
worksheet). 
return 0; 

Sample 1 Input 
Student Loan Interest Deduction Worksheet Program 

1 - Single 
2 - Married, Filing Jointly 
3 - Head of Household 
4 - Qualifying Widow(er) 
5 - Married, Filing Separately 
Enter your filing status from above (1-5): 5 


Sample 1 Output (early exit before line 1) 


Sample 2 Output (no early exit - uses sample inputs 2a and 2b from program description) 


Sample 3 Input 


Student Loan Interest Deduction Worksheet 

Filing Status: Married, Filing Jointly 

1. Total Interest Paid on Loans in 2012: 2222.00 

2. Total Income (from 1040 line 22): 145000.00 
3. Adjustments to Income (from 1040 lines 23-32): 2500.00 
4. Adjusted Income: 142500.00 
5. Income Limit: 120000.00 
6. Amount over Limit: 22500.00 
7. Percentage of deduction excluded: 0.750 
8. Amount excluded: 1666.50 

9. Student Loan Interest Deduction: 555.50 

***Enter amount from worksheet line 9 on form 1040 line 33 

Student Loan Interest Deduction Worksheet Program 

1 - Single 
2 - Married, Filing Jointly 
3 - Head of Household 
4 - Qualifying Widow(er) 
5 - Married, Filing Separately 
Enter your filing status from above (1-5): 3 

Enter Interest Paid on Student Loans: 3000 

Enter Total Income (from 1040 line 38): 50000 

Enter Adjustments to Income (from 1040, lines 23-32): 1000 

Student Loan Interest Deduction is not allowed for Married Filing Separately 

***Enter 0 on form 1040 line 33 
Sample 3 Output (skips lines 6 through 8) 

Sample Output Notes 

• Make sure there are a couple of blank lines AFTER all input has been entered and 
BEFORE the worksheet is displayed. 
• The filing status should be displayed in words (i.e. not a number), lined up on the right 
with the figures below it. 
• A married filing separately filing status may cause the program to exit without displaying 
the worksheet (see sample 1 above). 
• The decision on line 6 may cause the program to skip displaying lines 6, 7 and 8 (see 
sample 3 above). 
• If neither of the above happens, all lines of the worksheet will be displayed (see sample 2 
above). 
Hints 
• Remember to declare constants for all fixed values. 
• Use separate variables with descriptive names to store your calculations for each line. 
• Work on one line at a time. Make sure each line is working correctly before moving on to 
the next line and any subsequent calculations. 
• Use the sample inputs and outputs to help you test your program. 

Documentation 

1) Top of program comments must include: 
Your name, the course, and the assignment number 
What the program does including: 
What is Input 
Processing Performed 
What is Output 
Student Loan Interest Deduction Worksheet 

Filing Status: Head of Household 

1. Total Interest Paid on Loans in 2012: 2500.00 

2. Total Income (from 1040 line 22): 50000.00 
3. Adjustments to Income (from 1040 lines 23-32): 1000.00 
4. Adjusted Income: 49000.00 
5. Income Limit: 60000.00 

9. Student Load Interest Deduction: 2500.00 

***Enter amount from worksheet line 9 on form 1040 line 33 

2) Add comment for any constants/variables whose names are not completely descriptive. 

3) Add a comment above each user-defined function that includes: 
What the function does 
A description of the parameters that are input to the function 
A description of what is returned from the function

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Carpet costs include the cost of the carpet
Reference No:- TGS085876

Expected delivery within 24 Hours