-Using the previous example given in the photos. Please give a similar example (not the same one as photos) of a simple program using 2 variables that require user input, two constants that are initialized upon declaration, and either a decision or repetition control structure the program uses to control the flow of logic. 1) Provide a hand-tracing example that tests the program like previous example and explain the process. Thank you! Will give rating.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
-Using the previous example given in the photos. Please give a similar example (not the same one as photos) of a simple program using 2 variables that require user input, two constants that are initialized upon declaration, and either a decision or repetition control structure the program uses to control the flow of logic. 1) Provide a hand-tracing example that tests the program like previous example and explain the process. Thank you! Will give rating.
Because marital status is not "s", we move to the else branch of the outer if statement (line 36).
24 if (marital status == "s")
25
{
26
27
28
29
30
31
32
33
38
39
40
41
42
43
44
45
46
if (income <= RATE1_SINGLE_LIMIT)
{
43
44
}
else
{
34
35
36
37
Because income is not <= 64000, we move to the else branch of the inner if statement (line 42).
if (income <= RATE1_MARRIED_LIMIT)
{
tax1 = RATE1 * income;
}
tax1 = RATE1 * income;
}
else
{
tax1 = RATE1 * RATE1_SINGLE_LIMIT;
tax2= RATE2* (income - RATE1_SINGLE_LIMIT);
}
else
{
}
The values of taxl and tax2 are updated.
{
tax1 = RATE1 * RATE1_MARRIED_LIMIT;
tax2 = RATE2 * (income - RATE1 MARRIED_LIMIT);
}
tax1 = RATE1* RATE1_MARRIED_LIMIT;
tax2 = RATE2* (income - RATE1 MARRIED_LIMIT);
45
46
47 }
Their sum total_tax is computed and printed. Then the program ends.
48
49
50
51
52
53 }
Because the program trace shows the expected output ($10,400), it successfully demon-
double total_tax = tax1 + tax2;
cout << "The tax is $" << total_tax << endl;
return 0;
taxl
Ø
6400
taxl
marital
tax2 income status
80000 m
6400 4000
tax2
Ø
4000
marital total
income status tax
80000 m
10400
Q
Transcribed Image Text:Because marital status is not "s", we move to the else branch of the outer if statement (line 36). 24 if (marital status == "s") 25 { 26 27 28 29 30 31 32 33 38 39 40 41 42 43 44 45 46 if (income <= RATE1_SINGLE_LIMIT) { 43 44 } else { 34 35 36 37 Because income is not <= 64000, we move to the else branch of the inner if statement (line 42). if (income <= RATE1_MARRIED_LIMIT) { tax1 = RATE1 * income; } tax1 = RATE1 * income; } else { tax1 = RATE1 * RATE1_SINGLE_LIMIT; tax2= RATE2* (income - RATE1_SINGLE_LIMIT); } else { } The values of taxl and tax2 are updated. { tax1 = RATE1 * RATE1_MARRIED_LIMIT; tax2 = RATE2 * (income - RATE1 MARRIED_LIMIT); } tax1 = RATE1* RATE1_MARRIED_LIMIT; tax2 = RATE2* (income - RATE1 MARRIED_LIMIT); 45 46 47 } Their sum total_tax is computed and printed. Then the program ends. 48 49 50 51 52 53 } Because the program trace shows the expected output ($10,400), it successfully demon- double total_tax = tax1 + tax2; cout << "The tax is $" << total_tax << endl; return 0; taxl Ø 6400 taxl marital tax2 income status 80000 m 6400 4000 tax2 Ø 4000 marital total income status tax 80000 m 10400 Q
For example, let's trace the tax program with the data from the program run in Section 3.4. In
lines 13 and 14, taxl and tax2 are initialized to 0.
6 int main()
7 {
8
9
10
11
12
13
14
15
16
17
18
const double RATE1 = 0.10;
const double RATE2 = 0.25;
const double RATE1 SINGLE LIMIT = 32000;
const double RATE1 MARRIED LIMIT = 64000;
19
20
21
22
23
double tax1 = 0;
double tax2 = 0;
In lines 18 and 22, income and marital status are initialized by input statements.
double income;
cout << "Please enter your income: ";
cin >> income;
marital
tax tax2 income, status
0
0
cout << "Please enter s for single, m for married: ";
string marital_status;
cin >> marital_status;
Because marital status is not "s", we move to the else branch of the outer if statement (line 36).
24
if (marital status == "s")
25
26
27
28
29
if (income <= RATE1 SINGLE LIMIT)
{
}
tax1 = RATE1 * income;
thomasd007/iStockphota
Hand-tracing helps you understand
whether a program works correct-
ly.
marital
tax tax2 income, status
0
0 80000 m
Transcribed Image Text:For example, let's trace the tax program with the data from the program run in Section 3.4. In lines 13 and 14, taxl and tax2 are initialized to 0. 6 int main() 7 { 8 9 10 11 12 13 14 15 16 17 18 const double RATE1 = 0.10; const double RATE2 = 0.25; const double RATE1 SINGLE LIMIT = 32000; const double RATE1 MARRIED LIMIT = 64000; 19 20 21 22 23 double tax1 = 0; double tax2 = 0; In lines 18 and 22, income and marital status are initialized by input statements. double income; cout << "Please enter your income: "; cin >> income; marital tax tax2 income, status 0 0 cout << "Please enter s for single, m for married: "; string marital_status; cin >> marital_status; Because marital status is not "s", we move to the else branch of the outer if statement (line 36). 24 if (marital status == "s") 25 26 27 28 29 if (income <= RATE1 SINGLE LIMIT) { } tax1 = RATE1 * income; thomasd007/iStockphota Hand-tracing helps you understand whether a program works correct- ly. marital tax tax2 income, status 0 0 80000 m
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education