0% found this document useful (0 votes)
26 views2 pages

HW Answer Sheet LMCh3

This document is a lab manual answer sheet for a programming assignment with multiple short programming exercises. It includes exercises to write code to calculate a bill total, store and output table data, calculate trigonometric functions, and calculate a batting average, with tasks to complete the code, fix errors, and record results. Students are asked to provide copies of their code and screenshots of program output for parts of each exercise.

Uploaded by

cvsqu8484
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

HW Answer Sheet LMCh3

This document is a lab manual answer sheet for a programming assignment with multiple short programming exercises. It includes exercises to write code to calculate a bill total, store and output table data, calculate trigonometric functions, and calculate a batting average, with tasks to complete the code, fix errors, and record results. Students are asked to provide copies of their code and screenshots of program output for parts of each exercise.

Uploaded by

cvsqu8484
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Your Name and Date

Lab 3 Lab Manual Ch 3 Answer Sheet – 64 points total

* Be sure to paste code and screenshots of your executable (black) screen when asked.

Fill in the Blank (9 pts)

1. Answer:
2. Answer:
3. Answer:
4. Answer:
5. Answer:
6. Answer:
7. Answer:
8. Answer:
9. Answer:

bill.cpp (20 pts)

1. Complete the program so that a sample run inputting 22 for the number of items bought and 10.98
for the price of each item will produce the results below.
a. Copy of Code & Screenshot:

2. Once you have the program working, change the instruction:


cout << setprecision (2) << fixed << showpoint;
to
cout << setprecision(2) << showpoint;
Rerun the program with the same data given in Exercise 1 above and record your results. What do
you think the fixed attribute in the cout statement does?
a. Answer:

3. Now put the fixed attribute back in and change the instruction to make the precision 4. Rerun the
program with the same data given in Exercise 1 and record your results. What do you think the
setprecision( ) attribute in the cout statement does?
a. Answer:

4. Add the following directive to the program: #include <string> in the header. Alter the program
so that the program first asks for the name of the product (which can be read into a string
object) so that the following sample run of the program will appear….see lab manual for further
details
a. Copy of Code & Screenshot:

tabledata.cpp (5 pts)

1. Finish the code above by filling in the blanks and the instructions necessary to execute the following
sample run. Note that two or more data items can be input at one time by having at least one blank
space between them before hitting the enter key.
a. Copy of Code & Screenshot:

Righttrig.cpp (10 pts)

1. Fill in the missing statement so that the following sample run is implemented:
a. Copy of Code and Screenshot

2. Alter the program so that the sample run now looks like the following:

a. Copy of Code and Screenshot:

Batavg.cpp (20 pts)

1. Run this program and record the results. The batting average is ______________________.

2. There is a logic error in this program centering around data types. Does changing the data type
of batavg from int to float solve the problem?

a. Answer:
b. Make that change and run the program again and record the result.
i. Answer: The batting average is _______________________.
3. Continue to work with this program until you get the correct result. The correct result should be
0.292162. Do not change the data type of the two named constants. Instead, use a typecast to
solve the problem.
a. Copy of Code and Screenshot:

You might also like