COSC1415/COSC1436
Lab – Chapter 5A
Objective: To learn how to use looping structures, especially while loops, in a program
At the end of this lab you should know how to:
1. incorporate while loops in a program.
2. use selection, repetition, files and value-returning functions in a program.
Remember to put a line in each program that identifies you as the programmer.
Lab 5A1: Write a program that reads the radius of a circle from a file (circles.txt). The program should use value-returning functions to calculate the area and circumference. Declare π (pi) as a constant that equals 3.1416. The program should use a priming read and a while loop that terminates when there is no more data in the file. The output should be sent to a file and include a title and be displayed (with one decimal place) similar to what you see below. Don’t forget to put the <your name> statement in your program.
Radius Area Circumference
5.6 98.5 35.2
…
123.5 47877.7 775.7
Save a copy of the program and the output file.
Lab 5A2: Write a program that reads test scores (four scores for each student) from a file (tests.txt). The program should use value-returning functions to determine the test average. (The test average is the average of the three highest test scores.). The program should use priming read and a while loop that terminates when there is no more data in the file. The program should output the four test scores rounded to one decimal place and the average rounded to two decimal places to a file. The labeled output should look similar to what you see below: Don’t forget to put the <your name> statement in your program.
Test 1 Test 2 Test 3 Test 4 Average
75.0 85.0 95.0 65.0 85.00
…
87.5 91.5 66.5 78.5 85.83
Save a copy of the program and the output file.
When you have completed the entire lab, you should e-mail the assignment to me. The subject line should be – C++ CHAP5A LAB
The following five files should be attached to the e-mail
This assignment with your name
Program for Lab5A1 and its output file
Program for Lab5A2 and its output file
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more