Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 1: Calculating time taken to pay off credit card Problem. Create a program to calculate how many months it will take to pay off

Assignment 1: Calculating time taken to pay off credit card Problem. Create a program to calculate how many months it will take to pay off a credit card given current credit card balance, annual percentage rate, the monthly payment amount. Add 10% to the monthly payment and recalculate the number of months. Report the results in a table. Input: Prompt for the clients name the current credit card balance the Annual Percentage Rate (APR) the amount of money you can be paid monthly. Formula: n = log(1 (Ai/P))/log(1 + i) Where, n = Number of Months to payoff credit card A = Amount on credit card i = Monthly Rate (APR / 12) P = Monthly Payment Amount Constraints: Enter the APR as an integer. A 22% interest rate would be entered as 22. Have the program convert this to the correct rate: .22. Display the payoff months as a whole number - fractional months dont make sense. Use the literal MONTHS_IN_YEAR rather than 12 in formulas requiring the number of months (if you need any). Keep the Input, Processing, and Output sections of your code separate, use modular hierarchical design. Design functions to prompt and read client name, prompt and read API, prompt and read monthly payments, prompt and read current credit card balance, calculate the number of months (using helper functions as needed) and display the results in a tabulated form. Use one of the C++ libraries for the log() function. Output: Sample Run Discussion. The hardest part of this assignment is getting the formula right. Take your time and break it up into parts - dont try to fit the formula on one line. This will make it easier to debug as well. This program does not need loops or decisions. No input validation. You will need to include the iomanip library for output formatting. Use three decimal places of precision. You will also need the strings library. You will need to use basic functions so make sure to review the C++ programming guide for CISP301 review on this topic and refer Chapter 6 of the textbook and revise Functions material on Zybook. You will need to submit your design document (see the sample programming assignment document) and submit your code Program to Calculate Final Bill:The Software Engineering Process consists of Problem Analysis, Specification, Design, Development, Documentation, Testing, Debugging, Presenting. Work is done collaboratively using appropriate tools at each step of the process.Problem: Sam has a special offer to purchase two games from a computer game store. He may purchase one game at regular price and the second game can be selected from the rack that has 10% off. Accordingly Sam would like to purchase two computer games, gameOne and gameTwo. Sales tax is 8% of the total cost after discounts are applied. Sam is on a budget and he needs your help to select two games such that the final bill will be affordable for him. Your task is to write a program that inputs prices of two games and computes the final bill based on the above considerations to help Sam make his selection.Problem Analysis: Given the prices of the first and the second game, the requirement is to apply the given discount to the price of the second game, add this discounted price to the price of the first game, apply the sales tax to this total to arrive at the final bill for this selection of games.Given Specifications:Clarifying questions:1. What are the types and ranges of numbers to be input (is this console or file i/o)2. What are the input prompts (menu?) and output display formats3. What is the context and environment for this program4. Does input validation need to be done5. If so, what is the format (ie repeat until valid answer or exit)6. Does the program need to do this task repeatedly (menu driven with exit option for user?)Given Design Decisions: This is a non looping program, with starting message and prompts but no menu. User is assumed to have goodwill and is expected to enter acceptable values, No input validation. User may not comply and enter all sorts of input including very small, very large integers, floating point numbers, strings and characters. Results for invalid data will be unknown. Input / Output is done via keyboard/console. No files.Programming language C++Formula: Final Bill = 1.08 *( costOfGame1 + 0.90*costOfGame2)Algorithm: Display Message for UserPrompt for cost of first game cost Input the cost of the first game Prompt for cost of second game Input cost of second game Apply discount to cost second game Add cost of both games after discount Apply sales tax to the above total to get the final bill Display the final billProgram Constraints and Framework for IPO / Design Decisions:Indicate the variable names, types, and other design decisionsVariable name Type GameOnePricereal - inputGameTwoPricereal - inputresultreal - processingdiscountedPricereal - processingfinalPricereal - outputTest Chart: Include comments about input validation decisions and tests if any for invalid dataGameOnePriceGameTwoPriceFinalBill19.9929.9950.74 102030.24000-19.99-29.99-50.74 (unknown)helloworldunknownHierarchy Chart and Modular Designmain programpromptGameOnePricepromptGameTwoPriceinputGamePriceapplyDiscountapplyTaxcalculateFinalBilldispayFinalBilldisplayMessage Verification: Screen shot of output showing that program passes all valid tests and shows invalid results as expected for invalid data. Here is a sample successful run for valid values./************************************************************** * Title: Final Bill Calculation ** Author : John Doe w176534 ** Date : 1/13/2020 ** Description : Inputs cost of two computer games and * * calculates and displays the final bill after applying * * discount and tax ***************************************************************/#include #include using namespace std;const double DISCOUNT= 0.10;const double SALES_TAX = .08;void displayMessage(); // displays the purpose of the applicationvoid promptGameOnePrice(); // asks user to input cost of first game void promptGameTwoPrice(); // asks user to input cost of second gamedouble getGamePrice(); // inputs cost of a game from consoledouble applyDiscount(double amount); // applies discount to costdouble applyTax(double amoubt); // applies tax to total amountvoid displayFinalBill(double amountOne, double amountTwo, double finalAmount);//displays the final Billint main() { double gameOnePrice=0; // cost of the first game double gameTwoPrice=0; // cost of the second game double discountedPrice=0; // cost of second game after discount double finalPrice=0; // total price of two games after tax and discount double result=0; // total price of gameOne and discounted price of gameTwo displayMessage(); promptGameOnePrice(); gameOnePrice= getGamePrice(); promptGameTwoPrice(); gameTwoPrice= getGamePrice(); discountedPrice=applyDiscount(gameTwoPrice); result= gameOnePrice+discountedPrice; finalPrice = applyTax(result); displayFinalBill(gameOnePrice,gameTwoPrice,finalPrice);}void displayMessage() { cout<<"This program inputs cost of two computer games and calculates the final Bill. A discount of 10% is applied to the second game Sales tax of 8% is levied on the total cost "<>gamePrice; return gamePrice;}// inputs the cost of gameTwo and returns the price after deducting the discountdouble applyDiscount(double amount){ return amount - DISCOUNT*amount;}// inputs result ie total price of game one and discounted price of game two, applies the sales tax to this and adds this amount to the input. Returns the total final payable billdouble applyTax(double amount){ return amount + SALES_TAX*amount;}//outputs a tabulated break up in bill form of items purchased and final total post discount and tax.void displayFinalBill(double amountOne, double amountTwo, double finalAmount){ cout<.

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

Excel 2024 In 7 Days

Authors: Alan Dinkins

1st Edition

B0CJ3X98XK, 979-8861224000

More Books

Students also viewed these Databases questions

Question

1. How might volunteering help the employer and the employee?

Answered: 1 week ago