I dont know what they mean by undetermined character constant

#include <iostream.h>
#include <stdlib.h>

class student
{
char st_name[25];
char st_major[25];
int i_test1;
int i_test2;
int i_test3;
int i_average;
char ch_grade;
char ch_option;
public:
void getdata();
void processdata();
void putdata();
};

int main()
{
do{
student.getdata();
student.processdata();
student.putdata();
cout << "\n\nDo you want to continue(Y/N)?
cin.get(ch_option);
cin.get();
}while(student.ch_option != 'N');
}

void student::getdata()
{
        cout << "\n\nPlease enter Student's Name: ";
        cin.getline(st_name,25);

        cout << "\n\nPlease enter Student's Major: ";
        cin.getline(st_major,25);

        cout << "\n\nPlease enter Test Score 1: ";
        cin >> i_test1;

        cout << "\n\nPlease enter Test Score 2: ";
        cin >> i_test2;

        cout << "\n\nPlease enter Test Score 3: ";
        cin >> i_test3;
}

void student::processdata()
{
        i_average = (i_test1 + i_test2 + i_test3) / 3;

switch(i_average)
{
        case 9:
                ch_grade = 'A';
        break;

        case 8:
                ch_grade = 'B';
        break;

        case 7:
                ch_grade = 'C';
        break;

        case 6:
                ch_grade = 'D';
        break;

        default:
                ch_grade = 'F';
}
}

void student::putdata()
{
        cout << "Student Average";
        cout << "\n\n**********************************";
        cout << "\n\nStudent Name: " << st_name;
        cout << "\nStudent Major: " << st_major;
        cout << "\nTest Score 1: " << i_test1;
        cout << "\nTest Score 2: " << i_test2;
        cout << "\nTest Score 3: " << i_test3;
        cout << "\n\nAverage: " << i_average;
        cout << "\nGrade: " << ch_grade;
        cout << "\n\n\nDo you want to exit(Y/N)? " << ch_option;
}

Recommended Answers

All 3 Replies

I'm preety sure the error untermined character constant means you forgot to close a string in output with quotes.

I believe that occurs here:
cout << "\n\nDo you want to continue(Y/N)?

Needs to be:
cout << "\n\nDo you want to continue(Y/N)?"

Hope that helps

dear use this code it is fine now from sysntax errors
i hope you will understant from comments
you must first understant the concept of encapsulation and about public &
privateaccess specifiers and objects as well.
ok dear from Rizwan Yasin Khan

#include <iostream.h>
#include <stdlib.h>


class student
{
char st_name[25];
char st_major[25];
int i_test1;
int i_test2;
int i_test3;
int i_average;
char ch_grade;
//public data members should be declared here
//private & protected members cannot be accessed
//by other local programms.so declared it public
public:
char ch_option;
public:
void getdata();
void processdata();
void putdata();
};


int main()
{
//here you should create an object of class student
//then you can access the student class members(functionsor data)
student st;
do{
st.getdata();
st.processdata();
st.putdata();
//here you also misses the quotation marks close
//and semicolon
cout << "\n\nDo you want to continue(Y/N)? ";
//here you are using a class member without
//comunicating through the object
//as a class member cannot be accessed directly without
//its object. And 2nd thing is that if you want to access
//the member of a class in another class or method
//then it should be declared as public
cin.get(st.ch_option);
cin.get();
}while(st.ch_option != 'N');
}


void student::getdata()
{
cout << "\n\nPlease enter Student's Name: ";
cin.getline(st_name,25);


cout << "\n\nPlease enter Student's Major: ";
cin.getline(st_major,25);


cout << "\n\nPlease enter Test Score 1: ";
cin >> i_test1;


cout << "\n\nPlease enter Test Score 2: ";
cin >> i_test2;


cout << "\n\nPlease enter Test Score 3: ";
cin >> i_test3;
}


void student::processdata()
{
i_average = (i_test1 + i_test2 + i_test3) / 3;


switch(i_average)
{
case 9:
ch_grade = 'A';
break;


case 8:
ch_grade = 'B';
break;


case 7:
ch_grade = 'C';
break;


case 6:
ch_grade = 'D';
break;


default:
ch_grade = 'F';
}
}


void student::putdata()
{
cout << "Student Average";
cout << "\n\n**********************************";
cout << "\n\nStudent Name: " << st_name;
cout << "\nStudent Major: " << st_major;
cout << "\nTest Score 1: " << i_test1;
cout << "\nTest Score 2: " << i_test2;
cout << "\nTest Score 3: " << i_test3;
cout << "\n\nAverage: " << i_average;
cout << "\nGrade: " << ch_grade;
cout << "\n\n\nDo you want to exit(Y/N)? " << ch_option;
}
commented: Use code tags. +0

The "undetermined character constant" was just one error.
I fiddled with the code a little, take a look:

// student's grades     Dev C++

#include <iostream>
#include <ctype.h>    // toupper()

using namespace std;

class student
{
  private:
  char st_name[25];
  char st_major[25];
  int i_test1;
  int i_test2;
  int i_test3;
  int i_average;
  char ch_grade;
  //char ch_option;
  public:
  void getdata();
  void processdata();
  void putdata();
};


void student::getdata()
{
  cout << "\n\nPlease enter Student's Name: ";
  cin.getline(st_name,25);

  cout << "\n\nPlease enter Student's Major: ";
  cin.getline(st_major,25);

  cout << "\n\nPlease enter Test Score 1: ";
  cin >> i_test1;

  cout << "\n\nPlease enter Test Score 2: ";
  cin >> i_test2;

  cout << "\n\nPlease enter Test Score 3: ";
  cin >> i_test3;
}

void student::processdata()
{
  i_average = (i_test1 + i_test2 + i_test3) / 3;
  
  if (i_average >= 90) ch_grade = 'A';
  else if (i_average >= 80) ch_grade = 'B';
  else if (i_average >= 70) ch_grade = 'C';
  else if (i_average >= 60) ch_grade = 'D';
  else ch_grade = 'F';
 // your switch/case gave just about everybody an F
}

void student::putdata()
{
  cout << "Student Average";
  cout << "\n\n**********************************";
  cout << "\n\nStudent Name: " << st_name;
  cout << "\nStudent Major: " << st_major;
  cout << "\nTest Score 1: " << i_test1;
  cout << "\nTest Score 2: " << i_test2;
  cout << "\nTest Score 3: " << i_test3;
  cout << "\n\nAverage: " << i_average;
  cout << "\nGrade: " << ch_grade;
  // cout << "\n\n\nDo you want to exit(Y/N)? " << ch_option;
}


int main()
{
  student stud;  // needed!!
  char yn;
    
  do {
    stud.getdata();
    stud.processdata();
    stud.putdata();
    cout << "\n\nDo you want to continue(Y/N)?";  // corr
    cin >> yn;
    yn = toupper(yn);  // just in case 
    cin.get();         // wait
  } while(yn != 'N'); 
 
  system("PAUSE");   // optional Dev C++	
  return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.