1831615 Members
2177 Online
110027 Solutions
New Discussion

Re: C++

 
Russell_13
New Member

C++

what forum do i go to fo C++ help?
4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor

Re: C++

Assuming this is UNIX, 'Languages'.
If it ain't broke, I can fix that.
Russell_13
New Member

Re: C++

ok, well lets see if i can explain this. sorry about giving the whole code, but it all needs to be there.

I am trying to make a structure for student data, look at the //comments. then i need to enter data for this student and pass it to this structure. but when the y enter in the state it needs to validate the state from its function. (only CA, WY, TX, AZ, TN are the valid states, if valid print 0, if any other state is entered print 1, as error.. Ive been stuck on this for about 2 hrs trying to figure this out. please look :)


#include
#include
#include

using namespace std;


//struct student // this is my struc but it wont let me pass info.
//{
char fName;
char lName;
int iDnumber;
int iCredits;
int Tuition;
char Resident;
char state[3];
//};


int main()
{

int const Res_Cred = 250;
int const Max_Of_Res = 3350;
int const Non_Res_Cred = 450;
int const Max_Of_Nonres = 6000;


cout <<"Enter students First Name: ";
cin >> fName;
cin.ignore( 10000, '\n');

cout <<"Enter students Last Name: ";
cin >> lName;
cin.ignore( 10000, '\n');

cout << "Enter school id number: ";
cin >> iDnumber;
cin.ignore( 10000, '\n');

cout << "How many credits are you taking: ";
cin >> iCredits;
cin.ignore( 10000, '\n');

cout << "What state are you from example: CA: ";
cin >> state;
cin.ignore( 10000, '\n');

cout << "Are you a resident? (Y/N)";
cin >> Resident;
cin.ignore( 10000, '\n');

if ((Resident == 'Y') || (Resident == 'y'))
{
Tuition = iCredits * Res_Cred;
cout << "They are a Resident" <}
else
{
Tuition = iCredits * Non_Res_Cred;
cout << "They are Non Resident" <}

if((iCredits < 0) || (iCredits >20))
cout << "ERROR: STUDENTS DATA IS OUT OF RANGE"<
if (Tuition < Max_Of_Res)
cout << "They are a Part time Student" <else if (Tuition >= Max_Of_Res)
cout << "They are a Full Time Student" <
cout << setw(5) << "ID"
<< setw(12)<< "Credits" << endl
<< setw(5) << "...."
<< setw(12)<< "......." << endl
<< setw(5) << iDnumber
<< setw(9) << iCredits << endl;

return 0;
}
Adam J Markiewicz
Trusted Contributor

Re: C++

Mayby I'm dummy, but I've read everything several times and I can't figure out what the problem is...
I do everything perfectly, except from my mistakes
John O'Driscoll_1
New Member

Re: C++

Russell,

You've defined your data structure, but have not declared any variables of that data type. You need to create a student, eg

int const Max_Of_Nonres = 6000;
struct student fred;

Or perhaps an array of students:

struct student students[50];

Once you've done that, to access a variable within the structure you need to use the dot notation, eg:

students[n].iDnumber = 44;

Regards

John