Need HW help ASAP

Im very new to coding and I dont understand how to do this. can someone plz help? thanks

17. Write a complete program that will read your initials (first, middle, and last) and five test scores. Your program should then compute your test average and print all information in a reasonable form (using setw and setprecision of 4) with suitable messages. Display results should include:
a. The three initials
b. The five scores.
c. The average
You've already got a thread.
inputting/outputting the initials/scores/average is really easy. You should know how to do that by now.

Getting the average is simply adding ALL exams and dividing it by how many exams you are adding

I.E:
Exam1+Exam2+Exam3+Exam4+Exam5 divided by 5.

Here is an example using set precision/setw. From one of my old assignments

1
2
3
4
5
6
7
8
9
10
#include <iomanip> // I believe this has to be included for setw and setprecision to work
const int FW = 6;

cout << fixed << showpoint << setprecision(2);
	cout << "Charity:                                          " << setw(FW) << name << endl;
	cout << "Revenue generated from ticket sales:             $" << setw(FW) << revenGen << endl;
	cout << "Amount deducted for administrative overhead:     $" << setw(FW) << revenReduc << endl;
	cout << "Amount deducted for prize money:                 $" << setw(FW) << totalDist << endl;
	cout << "Bonus Contribution:                              $" << setw(FW) << contribution << endl;
	cout << "Balance raised for charitable fund:              $" << setw(FW) << totalMoney << endl;
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <iomanip>

using namespace std;

int main(void)
{
	//Variables for your initials here as such
	char firstInitial = NULL;
	char secondInitial = NULL;
	char thirdInitial = NULL;
	double firstTestScore = 0.0;		//double as a test score can be decimal
	double secondTestScore = 0.0;
	double thirdTestScore = 0.0;
	double fourthTestScore = 0.0;		//or you could use score1, score2 etc...
	double fifthTestScore = 0.0;
	double average = 0.0;		// Result of your tests all together

	cout << "Enter your first initial: ";
	cin >> firstInitial;

	cout << endl << "Enter your second initial: ";
	cin >> secondInitial;

	cout << endl << "Enter your third initial: ";
	cin >> thirdInitial;

	cout << endl << "Enter your first test score: ";
	cin >> firstTestScore;

	cout << endl << "Enter your second test score: ";
	cin >> secondTestScore;

	cout << endl << "Enter your third test score: ";
	cin >> thirdTestScore;

	cout << endl << "Enter your fourth test score: ";
	cin >> fourthTestScore;

	cout << endl << "Enter your fifth test score: ";
	cin >> fifthTestScore;

	average = (((firstTestScore + secondTestScore) + (thirdTestScore + fourthTestScore) + fifthTestScore)) / 5;  //basicly adds all your test scores and divides by 5

	cout << fixed << setprecision(4) << endl << "Your initials are: " << firstInitial << secondInitial << thirdInitial
		<< endl << "First test score: " << setw(4) << firstTestScore
		<< endl << "Second test score: " << setw(4) << secondTestScore
		<< endl << "Third test score: " << setw(4) << thirdTestScore				//what setprecision does is it shows 4 decimals after the .
		<< endl << "Fourth test score: " << setw(4) << fourthTestScore
		<< endl << "Fifth test score: " << setw(4) << fifthTestScore
		<< endl << "Average test score of: " << setw(4) << average << endl;

	return 0;
}



I hope that I explained it correctly feel free to use my code as a template and make sure you do understand before taking it for granted. :)
Topic archived. No new replies allowed.