Solved

Arrays and void statements

Posted on 2007-11-25
8
791 Views
Last Modified: 2012-06-21
O.k. heres the problem; we are doing arrays and strings. I have to write a program that outputs the following:
Class Average
Names of all the students whose test scores are below the class average
Highest Test score and the names of all the students having the highest score
The maximum number of students is 50.

Heres what the output should look like:

 Processing Data
Class size: 16
Highest score: 95
Students whose score is highest in the class: Duffy    Pluto    Balto   Minne
Class Average: 78.06
Students whose score is less than class average:
                             Johnson  Your score is below class average.
                          Robinson    Your score is below class average.
                           Ashtony    Your score is below class average.
                            Mickey      Your score is below class average.
                            Billy          Your score is below class average.
                            Danny       Your score is below class average.
                            Doc           Your score is below class average.
                           Duckey       Your score is below class average.
                            Anddy       Your score is below class average.


The input file looks like this:
Johnson 76
Miller 90
Duffy 95
Robinson 45
Ashtony 63
Goofy 89
Pluto 95
Mickey 72
Billy 76
Danny 56
Balto 95
Roony 87
Doc 67
Minne 95
Duckey 72
Anddy 76

   

Heres my program so far:

#include <iostream>
#include <fstream>

using namespace std;

void initialize(
void score(
void list(
void student(
void below(

int main()
{
    ifstream inData;
    ofstream outData;
   
    int lineCount;
    char ch;
   
    cout<<"Processing Data"<<endl;
   
    inData.open("C:\\Documents and Settings\\Owner\\My Documents\\Carrie\\carries2\\CSC160\\ch9_ex8data");
    if(!inData)
    {
               cout<<"Cannot open the input file."<<endl;
               return 1;
               }
    outData.open("C:\\Documents and Settings\\Owner\\My Documents\\Carrie\\carries2\\CSC160\\prog.out");    
      initialize (classSize);
      cout<<"Class size:"<<classSize<<endl;
      score(highest);
      cout<<"Highest Score:"<<highest<<endl;
      list(highSt);
      cout<<"Students whose score is the highest in the class:"<<highSt<<endl;
     
     
      student(average);
      cout<<"Class Average:"<<average<<endl;
      below(scores);
      cout<<"Students whose score is less than class average:"<<scores<<endl;
     
       inData.close()
       outData.close()
           
   
        system ("pause");
}  
void initialize(
void score(
void list(
void student(
void below(



Help! How do I finish this?
0
Comment
Question by:ccmeschke
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 40

Expert Comment

by:evilrix
ID: 20347596
>> Help! How do I finish this?
Bit of an ambiguous question :)

I presume this is homework of some kind? If so, you'll need to try your best and ask a specific Q when you get stuck.
0
 

Author Comment

by:ccmeschke
ID: 20347811
What I meant was, how do I get started in the void parameters? I think I have the arrays down, but I'm not sure how to do the void parameters. Any examples would be helpful.
0
 
LVL 28

Accepted Solution

by:
pepr earned 500 total points
ID: 20348877
Firstly, do the dummy implementations, just to make your compiler happy. Then implement the bodies of your functions one by one.

Apparently, this is only a skeleton -- no data processed. Probably your initialize() should fill some data structures and the other function should process the read data. For doing that, you should decide and implement the data structures. Then you will know what interface (arguments) the "void initialize(" should get.

The first occurence of "void initialize(" is the beginning of the future prototype of the function (i.e. declaration of the function (no body). The second occurence of the same should repeat the above prototype plus it must implement the functionality (i.e. you have to write the body of the function). You should pass references to the input stream and also reference or pointer to the data structure to be filled from the input stream. The size is not enough and possibly also not correct. But it may be acceptable limit given in the homework assignment.

Then implement the rest of functions.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20349323
>> I think I have the arrays down

You're not using any arrays ...


>> , but I'm not sure how to do the void parameters. Any examples would be helpful.

What do you mean by "void parameters" ??
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 28

Expert Comment

by:pepr
ID: 20349465
Infinity08: I remember days when I was teaching young artists. The subject was related to vector drawing programs (CorelDraw). I had to answer the questions like "How do I move that arrow?" "You have to move your mouse and it will move accordingly." One of them shouted "It does not work in my case!" while moving the mouse about 30 cm above the table.

The moral of the story is: Yes, we programmers are deformed by our job wher "file" means "the stored stream of bytes". The "void parameters" may mean "left out parameters".
0
 
LVL 40

Expert Comment

by:evilrix
ID: 20349469
Deep :)
0
 
LVL 40

Expert Comment

by:evilrix
ID: 20349472
BTW: I don't consider myself a programmer, I too am an artist: C++ is my canvas and the compiler my brush (or something like that) :-D
0
 

Author Closing Comment

by:ccmeschke
ID: 31410902
thank you that was very helpful. I started the parameters and ended up with a few errors because I forgot the references, but after reading your comments, I put them in. I think it's just about perfect, so thank you for your comments.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now