Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Need help with Functions Assignment from Class.
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
dropglock




PostPosted: Thu May 01, 2008 1:02 am   Post subject: Need help with Functions Assignment from Class.

Hello everyone I am new here and I am also new to C++. I am stuck here... this is what I have done so far. Can someone tell me what I did wrong(if any) and help me complete this assignment by tomorrow? The PDF of the assignment is in the attachment. If you are going to help me please limit your suggestions to only material under using void functions, Thanks.

code:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>

using namespace std;

void greeting();
void getName();

int main ()
{
        ifstream inputFile1, inputFile2;
        ofstream outputFile;

        string userInput, userInput2, data1, skip;

        cout << "Supply the input file name to process." << endl;
        cin >> userInput;

        inputFile1.open(userInput.c_str());
       
        if (inputFile1.fail())
        {
                cout << "The input file does not exist" << endl;
                cout << "Exit the program and try again..." << endl;
                return 0;
        }
        else
        {
                cout << "Supply the output file name to process." << endl;
                cin >> userInput2;
                inputFile2.open(userInput2.c_str());
        }
        if (inputFile2.fail())
        {
                cout << "The output file does not exist" << endl;
                cout << "Exit the program and try again..." << endl;
                return 0;
        }
        else
        {
                greeting();
                getName();
                while( !inputFile1.eof())
                {
                inputFile1 >> data1;
                }
        }
}

void greeting()
{
        cout << "Joe's Grading Calculator" << endl;
        cout << endl;
        cout << "==================================================" << endl;
}

void getName()
{
        ifstream inputFile1, inputFile2;
        ofstream outputFile;

        string userInput, userInput2, name, data1, skip;
        int t = 1;
        int tt = 1;

        inputFile1.open(userInput.c_str());
        inputFile2.open(userInput2.c_str());
        outputFile << "Joe's Grading Calculator" >> endl;                     // Come back to this later to see if things look correct.
        outputFile << endl;
        outputFile << "==================================================" >> endl;
        outputFile << endl;
        while (t = tt)
        {
        inputFile1 >> name;
        getline(inputFile1, name);
        getline(inputFile1, skip);
        outputFile << "Your name is: " << name << endl;
}



Functions_Assignment.pdf
 Description:
The PDF for the assignment.

Download
 Filename:  Functions_Assignment.pdf
 Filesize:  103.54 KB
 Downloaded:  277 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
jernst




PostPosted: Thu May 01, 2008 8:52 am   Post subject: Re: Need help with Functions Assignment from Class.

When i tried to compile the code it didnt like
code:
>> endl;

so I commented those out in getName(). Also your while loop in getName() is missing a closing bracket. I haven't read the assignment or what you need to do but that will get it to compile at least...
dropglock




PostPosted: Thu May 01, 2008 12:29 pm   Post subject: Re: Need help with Functions Assignment from Class.

Hey thanks.. it compiled now. Damn those small things i missed..

Now it's not outputting the stuff I told it to output too in the getName() function. But there are also no errors...
btiffin




PostPosted: Thu May 01, 2008 3:01 pm   Post subject: Re: Need help with Functions Assignment from Class.

Closely examine the while ( ... ) construct in getName.

As it is homework, that's all I say for now.

Cheers
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: