Assignment #5
Assignment #5
Assignment #5
1. Instructions:
(1) To finish and submit your assignment, please follow the steps below:
a. Create a word file with the name format: “FirstName_LastName”, for example:
“Haitao_Zhao”
b. For each problem:
Step 1: Write a C++ program.
Step 2: Compile and run it
Step 3: Test the program with all your test cases
Step 4: Debug the program if there are errors
Step 5: Repeat step 2-4 until there are not any errors
Step 6: Copy and paste your code to the word file.
Step 7: Run your program with your test cases, when the result is displayed on the console,
Take a screenshot and paste the output screenshot to the word file.
Step 8: repeat the step 7 if there are multiple test cases, and paste the separate screenshot
for each of your test cases.
Step 9: Submit the word file.
(2) For each program, points will be deducted if your program is:
*/
(3) An example:
*/
#include<iostream>
using namespace std;
int main () {
return 0;
}
2. Problems
Problem 1 (20 points): Write a program that displays the following table (note that 1 millimeter is
0.039 inches):
Millimeters Inches
2 0.078
4 0.156
...
96 3.744
98 3.822
Problem 2 (40 points): Write a program that uses a nested loop to display Pattern A below, followed
by another nested loop that displays Pattern B.
Pattern A: Pattern B:
Problem 3 (40 points): Download random.txt file from Canvas. This file contains a long list of random
numbers. Copy the file to the folder where you write a program that opens the file, reads all the
numbers from the file, and calculates the following:
A) The number of numbers in the file
B) The sum of all the numbers in the file (a running total)
C) The average of all the numbers in the file
The program should display the number of numbers found in the file, the sum of the
numbers, and the average of the numbers.