Oct 4, 2016 at 10:20am UTC
what am i doing wrong if a file prints out that:
Studnt ID Ex ------- Assignments ------- Tot Mi Fin CL Pts Pct Gr
-------- -- ----------------------------- --- -- --- -- --- --- --
99123632
20 6 16 11 12 8 18 12 16 18 18 135 13 69 68 305 76
A
010 77416383 27 12 9 19 18 20 14 17 17 18 171 20 9 61 77416644 19354161
054 88779035 21 2 20 7 7 18 15 20 9 88779154 19 17 18 88779216 22194804
063 82 10 79308212 30 3 13 16 20 18 20 18 79308360 10 14 20 79308486 19827121
016 59 72 10 93948440 28 10 10 18 18 11 19 93948636 16 1 4 93948716 23487179
013 19 58 67 1 57033520 30 16 12 12 14 8 57033738 20 20 14 57033811 14258452
017 20 17 35 85 10 1234567 23 14 12 17 20 1234800 17 13 17 1234867 308716
08 17 12 14 37 59 8 81024122 10 20 19 17 81024318 17 16 16 81024384 20256096
020 12 20 11 8 52 58 9 90249512 17 14 14 90249715 18 20 19 90249784 22562446
08 19 10 18 6 14 35 85 10 95088981 27 14 95089200 11 18 17 95089265 23772316
014 16 7 17 9 7 63 73 3 97689421 17 97689633 16 13 15 97689683 24422420
020 18 15 14 20 17 15 17 60 38 3 81525492 81525691 26 19 19 81525773 20381443
013 11 20 15 15 13 9 20 15 52 81 10 250 72738202 24 17 72738504 18184626
06 19 19 8 13 7 20 20 19 19 36 28 189 9 96977542 30 96977789 24244447
014 19 18 17 5 20 9 20 16 17 7 52 181 70 10 62379335 62379615 15594903
029 17 17 18 16 18 20 19 18 14 12 16 168 68 46 10 309 77
A
80785252
30 10 16 20 14 19 13 19 20 11 9 151 18 46 80 325 81
A
05 86098453 16 12 10 8 4 4 16 20 5 10 105 19 17 42 86098636 21524659
073 10 45129928 26 20 18 14 20 19 13 19 16 45130093 20 17 15 45130155 11282538
067 91 7 46268803 20 20 15 20 18 13 18 14 46268948 11 13 5 46269068 11567267
020 69 57 6 96778364 17 15 10 11 17 6 17 96778520 18 19 19 96778645 24194661
018 64 81 5 22119387 24 18 12 10 16 3 22119620 8 11 10 22119656 5529914
017 12 14 60 33 8 94687162 13 11 20 18 17 94687356 14 6 18 94687406 23671851
013 15 9 61 54 9 87479868 30 18 11 17 87480092 20 10 18 87480146 21870036
09 11 19 12 16 45 100 8 94877992 20 20 20 94878252 18 12 18 94878311 23719577
011 20 20 16 19 69 82 10 62286623 24 20 62286903 20 18 10 62286959 15571739
014 18 14 9 1 19 18 56 85 10 98935840 20 98936072 15 18 19 98936142 24734035
016 13 15 18 3 9 12 9 59 72 3 75307286 75307486 24 18 16 75307557 18826889
017 17 19 7 17 15 18 19 19 56 36 6 212 45597669 30 19 45597947 11399486
012 12 19 13 20 19 15 10 8 20 47 66 237 7 45386309 23 45386588 11346647
011 14 19 16 20 13 14 18 20 12 16 65 213 34 10 59069659 59069930 14767482
028 20 20 19 17 15 11 20 19 11 17 18 167 40 88 9 324 81
A
59526778
28 20 19 18 19 12 17 16 19 14 12 166 18 48 95 355 88
A
09 59042962 24 17 17 14 14 19 20 13 13 9 160 4 8 43 59043177 14760794
097 90308940 21 16 19 11 16 15 19 20 10 90309087 17 20 12 90309144 22577286
068 78 6 97467092 29 18 16 19 19 4 18 17 97467238 14 19 15 97467364 24366841
011 60 87 3 43528851 8 20 20 12 19 20 14 43529054 20 18 6 43529158 10882289
013 18 23 74 6 56259572 28 12 11 12 19 19 56259776 18 16 11 56259839 14064959
016 19 14 57 73 8 96729107 27 15 17 17 17 96729352 9 17 7 96729404 24182351
018 20 17 9 42 42 10 86407368 24 12 17 18 86407559 18 15 11 86407623 21601905
018 13 7 17 10 57 100 8 99557895 29 18 18 99558159 18 11 20 99558221 24889555
019 14 14 19 14 17 63 62 4 63678459 23 7 63678682 18 10 13 63678737 15919684
020 17 20 15 18 9 5 48 88 8 78534524 20 78534755 14 16 18 78534820 19633705
019 14 15 17 5 15 17 51 54 7 91417119 91417314 29 10 20 91417380 22854345
014 18 15 19 17 16 7 17 52 87 9 257 91999035 27 17 91999343 22999835
017 13 15 18 20 18 16 15 20 18 74 227 7 94019935 30 94020208 23505052
014 15 19 15 17 17 15 12 16 17 7 47 182 75 6 95138803 95139081 23784770
025 16 18 8 12 17 8 19 11 16 13 138 68 57 7 277 69
A
94584165
28 18 19 13 16 20 8 9 13 20 18 154 20 70 86 358 89
A
010 76543210 9 0 10 15 10 15 10 15 10 15 109 10 15 50 76543394 19135848
Program ended with exit code: 0
Oct 4, 2016 at 10:54am UTC
The problem is that you did not provide us with your code yet.
However, if you ask me, your output does not look very smooth. This indicates that your code has a problem.
Oct 4, 2016 at 4:36pm UTC
so sorry i didn't even noticed:
<
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string calc_grd(int precent) {
string grade;
if (precent < 60)
grade = "F" ;
if (precent >=60 && precent <=69){
if (precent == 60 || precent == 61)
grade = "D-";
else if (precent == 68 || precent == 69)
grade = "D+";
else grade = "D";
}
if (precent >=70 && precent <=79){
if (precent == 70 || precent == 71)
grade = "C-";
else if (precent == 78 || precent == 79)
grade = "C+";
else grade = "C";
}
if (precent >=80 && precent <=89){
if (precent == 80 || precent == 81)
grade = "B-";
if (precent == 88 || precent == 89)
grade = "B+";
else grade = "B";
}
if (precent <=90){
if (precent == 90 || precent == 91)
grade = "A-";
if (precent == 99 || precent == 100)
grade = "A+" ;
else grade = "A";
}
return grade;
}
int stu_line(int getline_Num,ofstream & outfile , ifstream & infile){
int Numline = 0;
int num = 0;
string line;
int assign[10];
int assign_sum = 0;
int pts_sum = 0;
int tot_prcnt = 0;
string grade;
for (Numline; Numline <= getline_Num;){
if (Numline == getline_Num){
infile >> num;
if (num <= 9999999)
outfile << "0" << num << " ";
else outfile << num << endl;
infile >> num;
if (num < 10)
outfile << " " << " ";
else outfile << num << " " ;
pts_sum += num ;
for (int a=0; a<10; a++){
infile >> num;
if (num < 10)
outfile << " " << num << " ";
else outfile << num << " ";
assign[a] = num ;
assign_sum += assign[a] ;
}
outfile << " " << assign_sum << " ";
pts_sum += assign_sum ;
for (int b=0; b<3; b++)
{
infile >> num;
outfile << num << " ";
if (num < 100)
outfile << " ";
if (b == 1 || (b == 2 && num < 10))
outfile << " ";
pts_sum += num;
}
outfile << pts_sum << " ";
tot_prcnt = (static_cast<double>(pts_sum)/400)*100;
outfile << tot_prcnt << " " << endl;
if (tot_prcnt < 100)
outfile << " ";
grade = calc_grd(tot_prcnt);
outfile << grade << "\n";
break;
}
else Numline++;
}
return 0;
}
int main() {
int x = 0;
string line;
ifstream infile;
infile.open("student_data.txt", ios::in);
ofstream outfile ("outputData.txt");
if (infile.is_open() && outfile.is_open())
{
cout << "Studnt ID Ex ------- Assignments ------- Tot Mi Fin CL Pts Pct Gr \n";
cout << "-------- -- ----------------------------- --- -- --- -- --- --- -- \n";
for (int x=1; x<=50; x++)
{
stu_line(x,outfile,infile);
}
infile.close();
outfile.close();
ifstream outfile;
outfile.open ("outputData.txt", ios::in);
while (! outfile.eof())
{
getline(outfile, line);
cout << line << endl;
}
outfile.close();
}
else cout << "Unable to open, try again.";
return 0;
}
>