Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Hi I'm confused can some help create a C++ program for this thanks Addison O'Reilly wants a program that calculates and displays the cost of

Hi I'm confused can some help create a C++ program for this thanks
image text in transcribed
image text in transcribed
image text in transcribed
Addison O'Reilly wants a program that calculates and displays the cost of a 4K Ultra HD TV, which is finally on sale at one of the stores in her area. The program should calculate the cost by multiplying the sale price by the state sales tax rate and then adding the result to the sale price. Figure 2-4 Problem specification for Addison O'Reilly When searching for the output, ask yourself the following question: What does the user want to see displayed on the screen, printed on paper, or stored in a file? The answer to this question is typically stated as nouns and adjectives in the problem specification. The problem specification in Figure 2-4 indicates that Addison (the program's user) wants to see the cost of the TV displayed on the screen; therefore, the output is the cost. In this context, the word cost is a noun. After determining the output, you then determine the input, which is also usually stated as nouns and adjectives in the problem specification. Here, look for an answer to the following question: What information will the computer need to know to display, print, or store the output items? It helps to think about the information that you would need to solve the problem manually because the computer will need to know the same information. In this case, to determine the cost, both you and the computer need to know the sale price and the sales tax rate; these items, therefore, are the input. In this context, sale, sales, and tax are adjectives, while price and rate are nouns. This completes the analysis step for the Addison O'Reilly problem. Some programmers use an IPO chart to organize and summarize the results of the analysis step, as shown in Figure 2-5. IPO is an acronym for Input, Processing, and Output. Figure 29 shows the problem specification and IPO chart for the Addison O'Reilly problem. Notice that each instruction in the algorithm starts with a verbs enter, calculate, and display. The algorithm begins by entering the input items. It then uses the input items to calculate the output item. An algorithm should state both what is to be calculated and how to calculate it. In this case, the cost is calculated by multiplying the sale price by the sales tax rate and then adding the result to the sale price. The last instruction in the algorithm displays the output item. To avoid confusion, it is important that the algorithm is consistent when referring to the input and output items. For example, if the input item is listed as sales tax rate, then the algorithm should refer to the item as sales tax rate rather than a different name, such as tax rate or rate. Figure 2-9 Problem specification and IPO chart for the Addison O'Reilly problem Step 3-Desk-Check the Algorithm After analyzing a problem and planning its algorithm, you then desk-check the algorithm: The term desk-checking refers to the fact that the programmer reviews the algorithm while seated at his or her desk rather than in front of the computer. Desk-checking is also called hand-tracing because the programmer uses a pencil and paper to follow each of the algorithm's instructions by hand. You desk-check an algorithm to verify that it is not missing any instructions and that the existing instructions are correct and in the proper order. Before you begin the desk-check, you first choose a set of sample data for the input values, which you then use to manually compufe the expected output value. For the Addison O'Reilly algorithm, you will use input values of $2300 and .05 (the decimal equivalent of 5% ) as the sale price and sales tax rate, respectively. A manual calculation of the cost results in \$2415, as shown in Eigure 2-12. Figure 2-12. Manual cost calculation for the first deskecheck

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions