need help with formatting

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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// -------------------------------------------------------------------------------
// COP 3014C Fundamentals of Programming
//
// Assignment ID:   PROG3
//
// File name:   students.cpp
//
// Author:   bfields Byron Fields
// 
// Description: Write a program to rearrange and format three lines of 
//              student data; data items are separated by whitespace.
//              Compute the average GPA of the students.
//  Due:   Sep 29 by 11pm
//    
//  NOTE:         THE DATA FOR EACH STUDENT IS ENTERED ON ONE INPUT LINE.
//              Input Line Content:  
//                      ID Firstname Lastname Courseload CumHours GPA Major
//
//              Output Line Content: 
//                      GPA ID CourseLoad CumHours Lastname Firstname Major
//
//                            +--------------+
//                            |              |
//          long Student_ID   |              |    float GPA
//                   -------->|   program    |-------------->
//          string FirstName  |  students    |    long Student_ID
//                   -------->|              |-------------->
//          string LastName   |              |    int CourseLoad
//                   -------->|              |--------------> 
//          int CourseLoad    |              |    int CumHours 
//                   -------->|              |--------------> 
//          int CumHours      |              |    string LastName
//                   -------->|              |--------------> 
//          float GPA         |              |    string FirstName
//                   -------->|              |--------------> 
//          string Major      |== work vars  |    string Major
//                   -------->|              |--------------> 
//                            |float         |
//                            | GPA_Sum      |    float avgGPA
//                            | wtGPA_Sum,   |--------------> 
//                            | cumHours_Sum;|    float wtAvgGPA
//                            |              |--------------> 
//                            +--------------+
//
// Example: 
//
//    Inputs: (NOTE: Major comes immediately after GPA, NO SPACE between them.)
//
//             143841138 Edward Jones 18 112 3.5Info Technology
//                    411384112 Miser Frugal 12   67   1.99Mech Engineering
//                118113428 Marilyn Sapp 6 31 3.828Business Administration
//
//   Outputs:      
//         
//
//             ==================
//             STUDENT GPA REPORT
//             ==================
//
//             GPA   StudentID  Load  Hours   Student_Name         Major
//             ----  ---------  ----  -----   ------------------- //                                                     --------------------
//             3.50  143841138    18    112   Jones, Edward        Info //              Technology
//             1.99  411384112    12     67   Frugal, Miser        Mech //Engineering
//             3.83  118113428     6     31   Sapp, Marilyn        Business //Administration
//
//             Average Student GPA   = 3.107
//             Weighted Average GPA  = 3.063
//---------------------------------------------------------------------------------

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{

long Student_ID;
string FirstName;
string LastName;
int CourseLoad;
int CumHours;
float GPA;
string Major;
float wtAvgGPA;
float GPA_Sum;
float wtGPA_Sum;
long Student_ID2;
string FirstName2;
string LastName2;
int CourseLoad2;
int CumHours2;
float GPA2;
string Major2;
long Student_ID3;
string FirstName3;
string LastName3;
int CourseLoad3;
int CumHours3;
float GPA3;
string Major3;


cout << "Enter Student ID" << endl;
cin >> Student_ID;

cout << "Enter First Name" << endl;
cin >> FirstName;

cout << "Enter Last Name" << endl;
cin >> LastName;

cout << "Enter Course Load" << endl;
cin >> CourseLoad;

cout << "Enter GPA and Major with NO SPACE between them" << endl;
cin >> GPA; 
cin >> Major;

cout << "Enter Student ID" << endl;
cin >> Student_ID2;

cout << "Enter First Name" << endl;
cin >> FirstName2;

cout << "Enter Last Name" << endl;
cin >> LastName2;

cout << "Enter Course Load" << endl;
cin >> CourseLoad2;

cout << "Enter GPA and Major with NO SPACE between them" << endl;
cin >> GPA2;
cin >> Major2;

cout << "Enter Student ID" << endl;
cin >> Student_ID3;

cout << "Enter First Name" << endl;
cin >> FirstName3;

cout << "Enter Last Name" << endl;
cin >> LastName3;

cout << "Enter Course Load" << endl;
cin >> CourseLoad3;

cout << "Enter GPA and Major with NO SPACE between them" << endl;
cin >> GPA3;
cin >> Major3;

float avgGPA = GPA_Sum / 3;


      
         

cout << "    ==================" << endl;
cout << "    STUDENT GPA REPORT" << endl;
cout << "    ==================" << endl;
cout << "    GPA   StudentID  Load  Hours   Student_Name         Major" << endl;
cout << "    ----  ---------  ----  -----   -------------------  --------------------" << endl;
cout << setw(70) << fixed << showpoint << setprecision(2) << GPA << Student_ID << CourseLoad << LastName << ", " << FirstName << Major << endl;
cout << setw(70) << fixed << showpoint << setprecision(2) << GPA2 << Student_ID2 << CourseLoad2 << LastName2 << ", " << FirstName2 << Major2 << endl;
cout << setw(70) << fixed << showpoint << setprecision(2) << GPA3 << Student_ID3 << CourseLoad3 << LastName3 << ", " << FirstName3 << Major3 << endl;
return 0;
} 


can anyone help me because the program does not even attempt to read the second and third sets of data and the format is way off.

this is what i get

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
Enter Student ID
2238667
Enter First Name
by
Enter Last Name
fi
Enter Course Load
22
Enter GPA and Major with NO SPACE between them
3.4Computer Engineering
Enter Student ID
Enter First Name
Enter Last Name
Enter Course Load
Enter GPA and Major with NO SPACE between them
Enter Student ID
Enter First Name
Enter Last Name
Enter Course Load
Enter GPA and Major with NO SPACE between them
    ==================
    STUDENT GPA REPORT
    ==================
    GPA   StudentID  Load  Hours   Student_Name         Major
   
--------------------
                                                                  3.40223866722fi, byComputer
                                                                  0.000-12613940, 
                           -251845381974328157947245886594378366976.00072636, 
 
Line 151 is using GPA_Sum without it being initialized to anything
Topic archived. No new replies allowed.