0% found this document useful (0 votes)
17 views3 pages

Lab Report 4 (312023705003)

The lab report outlines 4 tasks for a programming assignment: 1) a program to input and output student data to a file, 2) a program to read student data from the file and output averages, 3) a program to calculate purchase costs based on quantity discounts, and 4) a menu-driven geometry calculator to compute areas of shapes by user selection. The tasks are designed to practice file input/output and decision-making structures in C++. Students are to complete the tasks, submit all source code and output, and write a concluding lab report.

Uploaded by

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

Lab Report 4 (312023705003)

The lab report outlines 4 tasks for a programming assignment: 1) a program to input and output student data to a file, 2) a program to read student data from the file and output averages, 3) a program to calculate purchase costs based on quantity discounts, and 4) a menu-driven geometry calculator to compute areas of shapes by user selection. The tasks are designed to practice file input/output and decision-making structures in C++. Students are to complete the tasks, submit all source code and output, and write a concluding lab report.

Uploaded by

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

Lab Report Four

1. You have to hand in a Lab report, all source code, and snapshots
of program output or results before the deadline. If you miss the
deadline, just get half mark for this assignment.
2. If anybody copies any code from another student, both of them get
0 mark.
3. Lab Target
(1) To understand and practice file input and output
(2) To understand and practice decision making structure
4. Tools
Operation System: : Not limited
Programming Language: C++ Programming Language
Textbook: Starting Out with C++ Early Objects

5. Tasks (After finish the following tasks, hand in Lab Reports, all source code,
and snapshot of running results)
5.1 Task One
Every student has the information as below: studentID(integer),
math(float),chinese(float),computer(float) . Make a program to input n(n=2~4)
students' information via the keyboard and writes the achievement information of
n students in a file named as "score.txt".

5.2 Task Two


After you finish the last task, you have a file that contains the information of n
students. Please make a program to read the information from the file "score.txt".
You should output the average score for every student on screen. Suggestion
interface is as below, but not limited to (Change the data if you want):
5.3 Task Three : A software company sells a package that retails for $99. Quantity
discounts are given according to the following table

Write a program that asks for the number of units purchased and computes the total
cost of the purchase. Input Validation: Make sure the number of units is greater
than 0.

5.4 Task Four: Write a program that displays the following menu (use switch...case
structure):
Geometry Calculator
1. Calculate the Area of a Circle
2. Calculate the Area of a Rectangle
3. Calculate the Area of a Triangle
4. Quit
Enter your choice (1-4):
If the user enters 1, the program should ask for the radius of the circle and then
display its area. Use 3.14159 for . If the user enters 2, the program should ask
for the length and width of the rectangle, and then display the rectangle’s area. If
the user enters 3, the program should ask for the length of the triangle’s base and
its height, and then display its area. If the user enters 4, the program should end.
Input Validation: Display an error message if the user enters a number outside the range of
1 through 4 when selecting an item from the menu. Do not accept negative values for the
circle’s radius, the rectangle’s length or width, or the triangle’s base or height.
The execution of the program may look like the following:

Conclusion
In conclusion, these exercises were really challenging for me and at the same time
interesting because of using new knowledges in practice. Especially, the exercise 3
was useful to understand the “switch case” very well. Additionally, opening the txt

file by writing code was unexpected experience 😊

You might also like