I know a bit but Im no specialist, whats your problem?
it'd be alot cooler if someone did![]()
I know a bit but Im no specialist, whats your problem?
Write a program that reads records from an input file (prog5inp.txt). Each record contains a student ID#, the student’s semester average, and the student’s assigned letter grade. The program determines how many of each letter grade was assigned and writes in tabular form the input values plus the ‘calculated’ values to an output file, prog5out.txt. Do not use functions other than main to solve this problem. All code should be kept inline. Do not use classes or arrays.
I'm supposed to use a count loop
general form
declare loop index variable
for (initialize loop index variable; test logical expression ; increment)
{
execute statement(s);
}
e.g.
#include <iostream>
int main()
{
int i;
for (i = 4; i >= 1; i = i - 1)
{
cout << " o" << endl;
}
return 0;
}
this is an example of a count loop, i'm just not sure how to plug it in to the program using what I need. C++ is so particular which makes it so complicated
I'm not familiar with the term "count loop" if that has a meaning of its own, but it doesn't seem like a really hard program to do.
You read the input file, while the id doesnt changes for each record you add one to the according counter (one for each possible grade letter).
Once the Id changes you write the output record with the totals in the counters, and then you reset them to zero.
so then(using previous example)~
#include <iostream>
int main()
{
int number_of_student;
for (number_of_student = 1; number_of_student >= 1; number_of_student = number_of_student + 1)
{
cout >> student_id >> student_smstr_avg >>
student_grade;
}
return 0;
}
??
thats totally wrong isnt it?
In C, for acts as a while structure, so you could do something like this
int main()
{
openfile
for (file.movefirst; file.eof(); file.movenext)
{
count grades and write output
}
closefile
return 0;
}
Sorry, I dont remember C++ syntaxis
how does it know when to stop?
When the Id changes, you'd need to store in a variable the previous read Id.
thanks danyel, i'll try it out some more
VB's kinda ok if you're into Windows.
I learned C/C++ because I had to for EE, but I wouldn't be caught dead programming something for myself in those languages. I like Ruby, Perl and Python best.
Someone needs us to do this/her homework?
Can't you just copy most of what you need out of your textbook? You know, that thing made out of dead trees that you are supposed to read.
no asshole
my dumbass teacher told us we probably wouldnt need the textbook
now i'm here wondering if I somehow got stuck into an upper level programming course where everyone seems to be 10 lessons ahead of me
That problem you were assigned is pretty simple. It's par for an introductory course.
But, as with any class in CS/SE/programming, it's normal to see people who are light years ahead of you.
It would be very simple were it not for the conditions she placed on the program.
i think i'm one of two people in that class who are not CS majors![]()
You don't need classes or arrays for this problem.
I agree that not being able to use functions is pretty ing stupid, though. That just makes your program longer and harder for your teacher to read, and harder to debug.
That is pretty basic logic for any programming class. But if most people in your class are way ahead of you, she may be adjusting how she teaches to their level. Sorry![]()
I disagree. I think for a basic class, they are learning the logic behind the functions.
it's cool, ive pretty much come to terms with it, but what pisses me off is that she is making little to no effort to help me along.
3 summer classes = little time to devote to each outside of class
I truly abhor C and C ++ programming languages.
Well, that's true. Some students learn better with the sadistic approach![]()
Shrda, c++ was the language people are taught in high school, brah.
There are currently 1 users browsing this thread. (0 members and 1 guests)