GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Feb-2005, 10:14
blackstone99 blackstone99 is offline
New Member
 
Join Date: Feb 2005
Posts: 1
blackstone99 is on a distinguished road

Getinput error. Error 2660. 4244, and 2447


Hello,
I'm getting a compiler error 2660, 4244, 2447 with the getinput function in my program. I've made several attempts to correct the error, but i can't figure it out. Any suggestions?

Blackstone99
CPP / C++ / C Code:
/*********************************************************************

  Filename:  studentrecord.cpp
  
  Program Description:

* This program gets student information from previous and current quarters.It
* then calculates and displays the new cumulative GPA, current GPA,
* total credits, and student ID .


*********************************************************************/


#include <iostream.h> // cin, cout
#include <iomanip.h> // setprecision(), setiosflags()

void getInput(char [], int,int &, float &, int &,int &,float & );
void doCalculations(int &, float &, int &, float &, float &, int &, float &);
void displayOutput(char [], int, float, float);

float calculateGPA(int, int);
float calculateTotalGPA(float, int, float, int);
int calculatetotalcredits(int,int);



/*******************************************************************************
* Function: main()
* Description: Gets student information from the keyboard, performs calculations
* on it, then prints it to the screen.
* Inputs: Reads input from the keyboard.
* Outputs: Writes output to the screen.
* Preconditions: <None>
* Postconditions: Prints to the screen and takes input from the keyboard.
*******************************************************************************/
void main(void)
{
const int studentIDLength = 10;      // Length of studentID[]
char studentID[studentIDLength];    // Student ID#
int previousCredits;                 // Number of credits previously
int previouscoursegrades;         // Number of previous grade points
float currentGradePoints;             // Number of honor points this quarter                                                          // completed
float previousGPA;                  // Previous GPA
int currentCredits;                  // Number of credits this quarter
int currentcourses;                  // Number of courses taken this quarter
float currentGPA;                    // GPA for this quarter
int totalCredits;                    // Total credit units
float totalGPA;                     // Overall GPA

//
// Get input from user.
//
getInput(studentID, studentIDLength, previousGPA,
previousCredits, currentcourses, previouscoursegrades);



//
// Perform calculations.
//
doCalculations(currentGPA, totalGPA, totalCredits);

//
// Output results.
//
displayOutput(studentID, currentGPA, totalGPA, totalCredits);
}


/*******************************************************************************
* Function: getInput()
* Description: Prompts for input and takes input for eight variables
* Inputs: All input is taken from the keyboard
* Outputs: All prompts are output to the screen
* Preconditions: studentID entered from keyboard must be no longer than
* studentIDLength - 1. studentName entered from keyboard must be
* no longer than studentNameLength - 1. Only integer
* numbers must be entered where integers are expected. Only
* floating point numbers must be entered where floating point
* numbers are expected.
* Postconditions: Output is displayed on screen. studentID{},
* currentGPA,totalCredits, totalGPA. 
* variables are modified.
*******************************************************************************/
void getInput(/* Out */ char studentID[],      // Student ID#
/* In */ int studentIDLength,                  // Length of studentID[]
/* Out */ int &previousCredits,                // Number of credits previously
/* Out */ float &previousGPA,                  // Previous GPA
/* Out */ int &previouscoursegrades,           // Number of previous honor points  
/* Out */ int &currentCredits,                // Number of credits this quarter
/* Out */ int &currentcourses,               // Number of courses taken this quarter
/* Out */ float &currentGradePoints);          // Number of grade points
    
{
                                                                              
{
int previouscredits; // Number of credits from input
int previouscoursegrades; // Number of grade points from input

currentCredits = 0;
currentGradePoints = 0;
currentcourses= 0;

//
// Prompt for input and get input from keyboard.
//
cout << "Student ID#: ";
cin.getline(studentID, studentIDLength);

cout << "Previous GPA: ";
cin >> previousGPA;

cout << "Previous number of credits: ";
cin >> previousCredits;

cout << "Previous Grade Points: ";
cin >> previouscoursegrades;

cout << "Previous Grade Points: ";
cin >> currentCredits;

cout << "Number of couses taken: ";
cin >> currentcourses;


//
// Get credit unit values and grades from one line of input from keyboard.
//
cout << "Credit unit values and grades: ";
for(int i = 0; i < currentCourses; i++)
        {
                cin >> previouscredits;
                cin >> previouscoursegrades;

                currentCredits += previouscredits;
                currentGradePoints += previouscoursegades* credits;
        }
}


/*******************************************************************************
* Function: doCalculations()
* Description: Performs the calculations and returns the results through the
* parameters.
* Preconditions: <None>
* Postconditions: Changes currentGPA, totalCredits and totalGPA.
*******************************************************************************/
void doCalculations(
                                                                                                
/* In */ int &previousCredits,                // Number of credits
/* In */ float &previousGPA,                  // Previous GPA
/* In */ int &currentCredits,                 // Current credits 
/* In */ float &currentGradePoints,           // Number of grade
/* Out */ float &currentGPA,                 // GPA for this quarter
/* Out */ int &totalCredits,                 // Total credit units
/* Out */ float &totalGPA,                   // Overall GPA
                                                                                                // quarter
{

	
currentGPA = calculateGPA(currentGradePoints, currentCredits);

totalCredits = calculatetotalcredits(previousCredits, currentCredits);

totalGPA = calculateTotalGPA(previousGPA, previousCredits, currentGradePoints,
totalCredits);



}


/*******************************************************************************
* Function: calculateGPA()
* Description: Given a the number of grade points and credits, this function
* calculates and returns the GPA.
* Preconditions: credits must not be zero.
* Postconditions: Returns the resulting GPA.
*******************************************************************************/
float calculateGPA(/* In */ float currentGradePoints,      // Number of grade points
/* In */ int currentcredits)                                                     // Number of credits
{
float GPA; // Grade Point Average

GPA = currentGradePoints / currentcredits;

return GPA;
}


/*******************************************************************************
* Function: calculateTotalGPA()
* Description: Given the previous quarter's GPA, the previous quarter's
* credits, the current quarter's grade points and the total
* credits earned overall, this function calculates and returns
* the overall GPA.
* Preconditions: totalCredits must not be zero.
* Postconditions: Returns the resulting overall GPA.
*******************************************************************************/
float calculateTotalGPA(/* In */ float previousGPA,      // Previous GPA
/* In */ int previousCredits,                            // Number of credits
                                                                                                  // previously
                                                                                                  // completed
/* In */ float currentGradePoints,                       // Number of grade
                                                                                                  // points this
                                                                                                  // quarter
/* In */ int totalCredits)                                  // Total credits for all
                                                                                                 // quarters
{
float totalGPA; // Overal GPA for all quarters

//
// Calculate overall GPA.
//
totalGPA = (previousGPA * previousCredits + currentGradePoints) / totalCredits;

return totalGPA;
}




/*******************************************************************************
* Function: displayOutput()
* Description: Prints the results of the calculations to the screen.
* Outputs: Prints all output to the screen.
* Preconditions: <None>
* Postconditions: Output is printed to the scree.
*******************************************************************************/
void displayOutput
(/* In */ char studentID[],               // Student ID#

/* In */ int totalCredits,            // Total credits completed
/* In */ float totalGPA,              // Overall GPA
/* In */ float currentGPA,            // GPA for this quarter
{

//
// Print results to screen.
//
cout << "Student ID#: " << studentID << endl;
cout << "Total number of credit units: " << totalCredits << endl;
cout << "Cumulative GPA: " << setprecision(2)
        << setiosflags(ios::fixed | ios::showpoint) << totalGPA << endl;
cout << "GPA for the current quarter: " << setprecision(2)
        << setiosflags(ios::fixed | ios::showpoint) << currentGPA << endl;


}
return 0;
Last edited by LuciWiz : 26-Mar-2006 at 09:17. Reason: Please insert your C++ code between [c++] & [/c++] tags
  #2  
Old 13-Feb-2005, 19:11
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,703
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
Quote:
Originally Posted by blackstone99
Hello,
I'm getting a compiler error 2660, 4244, 2447 with the getinput function in my program. I've made several attempts to correct the error, but i can't figure it out. Any suggestions?
CPP / C++ / C Code:
void doCalculations(
                                                                                                
/* In */ int &previousCredits,                // Number of credits
/* In */ float &previousGPA,                  // Previous GPA
/* In */ int &currentCredits,                 // Current credits 
/* In */ float &currentGradePoints,           // Number of grade
/* Out */ float &currentGPA,                 // GPA for this quarter
/* Out */ int &totalCredits,                 // Total credit units
/* Out */ float &totalGPA,                   // Overall GPA
                                                                                                // quarter
{

I'm all for comments, but this style almost completely obscures what's going on.

Specifically, you don't have a closing parenthesis on the declaration
CPP / C++ / C Code:
void doCalculations( int    &previousCredits,    // Number of credits
                     float &previousGPA,         // Previous GPA
                     int   &currentCredits,      // Current credits 
                     float &currentGradePoints,  // Number of grade
                     float &currentGPA,          // GPA for this quarter
                     int   &totalCredits,        // Total credit units
                     float &totalGPA,            // Overall GPA
                       //Are there more?                                                                          // quarter
{

Now the prototype looks like this:
CPP / C++ / C Code:
  void doCalculations(int &, float &, int &, float &, float &, int &, float &);

So is totalGPA the last?

You invoke the function like this:
CPP / C++ / C Code:
  doCalculations(currentGPA, totalGPA, totalCredits);

Only three arguments???

Seems like there's some work to be done.

When the compiler gave you the messages is the three you mentioned all that it said? What line numbers did it give you? (Some times the compiler gets almost as confused as I do, and the line numbers might not match up exactly with the errors (line numbers in messages are sometimes somewhat later in the program than the actual errors).

Are there any particular reasons that you are passing all of the arguments by reference? (Just curious.)

Regards,

Dave
 
 

Recent GIDBlogHalfway done! by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:56.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.