Jump to content

problems in running the program

- - - - -

  • Please log in to reply
7 replies to this topic

#1
rissa

rissa

    Newbie

  • Members
  • Pip
  • 4 posts
below is the program that i already create..but there were so many error..
can somebody help me?? hehehee


#include<iostream>
using namespace std;


void pilih(char, char[][3], int, int);
void display(char[][3]);

void isi(char*, int, char, char [][3], int);
bool rules(char [][3]);
void decide(bool, int);
void menu();
bool select(char&);
bool menuBack(bool);

char grade( double mark);


int main()
{
char num;
bool back;


do
{
menu();
back = select(num);
}
while(back == true);
    system("pause");
}
void menu()
{
cout<<"\n------------WELCOME TO TIC TAC TOE GAME!!----------------"<<endl;
cout<<"---------------------------------------------------------"<<endl;
cout<<"| MENU |"<<endl;
cout<<"| |"<<endl;
cout<<"|1) ABOUT PROGRAMMERS 4) STUDENTS GRADE |"<<endl;
cout<<"| |"<<endl;
cout<<"|2) ABOUT GRADING 5) EXIT |"<<endl;
cout<<"| |"<<endl;
cout<<"|3) INSTRUCTIONS |"<<endl;
cout<<"| |"<<endl;
cout<<"| |"<<endl;
cout<<"| THANK YOU!!! :) |"<<endl;
cout<<"---------------------------------------------------------"<<endl;
}


bool select(char& num)
{
int nums;
bool back2Menu = false;
bool kembali = false;
cout<<"\nEnter your choice: ";
cin>>num;
cout<<endl;
system("cls");
nums = static_cast<int>(num);
nums -= 48;
if(nums>=1 && nums<=5)
{
switch (nums)
{
case 1:
   {
    cout<<"\n ABOUT PROGRAMMERS "<<endl;
    cout<<" ----------------- "<<endl;
    cout<<"\n1)SITI FATIMAH BT MORAD 2009868978 EE2503A "<<endl;

kembali = menuBack(back2Menu);
system("cls");
}
break;
    case 2:
       {
int numStud;
int numTest;
int numQuiz;

cout<<"*******************************************"<<endl;
cout<<"---------Students grade---------------------"<<endl<<endl;
cout<<"Please enter the number of students' data : ";
cin>>numStud;
cout<<"Number of test:";
cin>>numTest;
cout<<"Number of quiz:";
cin>>numQuiz;

string nameStud[numStud];
string id[numStud];
string part[numStud];
string code[numStud];

double test;
double quiz;
double fin;
string gred[numStud];

for(int c = 0; c<numStud; c++)
{
cout<<"Enter student name:";
cin>>nameStud[c];
cout<<"Enter student ID:";
cin>>id[c];
cout<<"Enter part:";
cin>>part[c];
cout<<"Enter course code:";
cin>>code[c];
double totalT = 0;
for(int t=0; t<numTest; t++)
{
    cout<<"Enter Test "<<(t+1)<<":";
    cin>>test;
    totalT += test;
}
double totalQ = 0;
for(int q=0; q<numQuiz; q++)
{
    cout<<"Enter Quiz "<<(q+1)<<":";
    cin>>quiz;
    totalQ += quiz;
}

cout<<"Enter final examination mark : ";
cin>>fin;
fin*=(60/100);
double total = totalT+totalQ+fin;

cout<<"The mark you get: "<<total<<endl;
cout<<"The gred :\n"<<grade(total);
}

return 0;
}

char grade( double mark);
{
char gred='a';
if(mark>=80 && mark<=100)
    gred = 'A';

else if(mark>=70 && mark<80)
    gred = 'B';

else if(mark>=60 && mark<70)
    gred = 'C';

else if(mark>=50 && mark<60)
    gred = 'D';

else if(mark>=40 && mark<50)
    gred = 'E';

else if(mark>=0 && mark<40)
    gred = 'F';
return gred;
}

}
 break;
     case 3:
       {
    cout<<"\n INSTRUCTIONS "<<endl;
    cout<<" ------------ "<<endl;
    cout<<"\n1) Enter the student name properly. "<<endl;
    cout<<"2) it is continue by the matrix number without exceed the maximum num of 10. "<<endl;
    cout<<"3) Next,enter the part and the course. "<<endl;

    cout<<"4) Then,select the place you want to use "<<endl;

    cout<<"\n\n THANK YOU!!!"<<endl;
kembali = menuBack(back2Menu);
system("cls");
}




{
menu();
select(num);
}






bool menuBack(bool back2Menu);

char back;
do
{
cout<<"\nBack to menu press 'M' or 'm'."<<endl;
cin>>back;
cout<<endl;
if(back == 'M' || back == 'm')
back2Menu = true;
}
while(back2Menu == false);


return back2Menu;
}
}

Edited by WingedPanther, 09 October 2010 - 04:50 AM.
add code tags (the # button)


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
First problem: you didn't use code tags (the # button) when you posted. I fixed that.

Second problem: your poor formatting is causing you to miss the fact that you have closed off blocks of code early/late on a regular basis. Here is the formatted code:
#include<iostream>
using namespace std;


void pilih(char, char[][3], int, int);
void display(char[][3]);

void isi(char*, int, char, char [][3], int);
bool rules(char [][3]);
void decide(bool, int);
void menu();
bool select(char&);
bool menuBack(bool);

char grade( double mark);


int main()
{
  char num;
  bool back;
  do
  {
    menu();
    back = select(num);
  }
  while(back == true);
  system("pause");
}

void menu()
{
  cout<<"\n------------WELCOME TO TIC TAC TOE GAME!!----------------"<<endl;
  cout<<"---------------------------------------------------------"<<endl;
  cout<<"| MENU |"<<endl;
  cout<<"| |"<<endl;
  cout<<"|1) ABOUT PROGRAMMERS 4) STUDENTS GRADE |"<<endl;
  cout<<"| |"<<endl;
  cout<<"|2) ABOUT GRADING 5) EXIT |"<<endl;
  cout<<"| |"<<endl;
  cout<<"|3) INSTRUCTIONS |"<<endl;
  cout<<"| |"<<endl;
  cout<<"| |"<<endl;
  cout<<"| THANK YOU!!! :) |"<<endl;
  cout<<"---------------------------------------------------------"<<endl;
}


bool select(char& num)
{
  int nums;
  bool back2Menu = false;
  bool kembali = false;
  cout<<"\nEnter your choice: ";
  cin>>num;
  cout<<endl;
  system("cls");
  nums = static_cast<int>(num);
  nums -= 48;
  if(nums>=1 && nums<=5)
  {
    switch (nums)
    {
      case 1:
        {
          cout<<"\n ABOUT PROGRAMMERS "<<endl;
          cout<<" ----------------- "<<endl;
          cout<<"\n1)SITI FATIMAH BT MORAD 2009868978 EE2503A "<<endl;
      
          kembali = menuBack(back2Menu);
          system("cls");
        }
      break;
      case 2:
      {
        int numStud;
        int numTest;
        int numQuiz;
        
        cout<<"*******************************************"<<endl;
        cout<<"---------Students grade---------------------"<<endl<<endl;
        cout<<"Please enter the number of students' data : ";
        cin>>numStud;
        cout<<"Number of test:";
        cin>>numTest;
        cout<<"Number of quiz:";
        cin>>numQuiz;
        
        string nameStud[numStud];
        string id[numStud];
        string part[numStud];
        string code[numStud];
        
        double test;
        double quiz;
        double fin;
        string gred[numStud];
        
        for(int c = 0; c<numStud; c++)
        {
          cout<<"Enter student name:";
          cin>>nameStud[c];
          cout<<"Enter student ID:";
          cin>>id[c];
          cout<<"Enter part:";
          cin>>part[c];
          cout<<"Enter course code:";
          cin>>code[c];
          double totalT = 0;
          for(int t=0; t<numTest; t++)
          {
            cout<<"Enter Test "<<(t+1)<<":";
            cin>>test;
            totalT += test;
          }
          double totalQ = 0;
          for(int q=0; q<numQuiz; q++)
          {
            cout<<"Enter Quiz "<<(q+1)<<":";
            cin>>quiz;
            totalQ += quiz;
          }
          
          cout<<"Enter final examination mark : ";
          cin>>fin;
          fin*=(60/100);
          double total = totalT+totalQ+fin;
          
          cout<<"The mark you get: "<<total<<endl;
          cout<<"The gred :\n"<<grade(total);
        }
        
        return 0;
      }
    
      char grade( double mark);
      {
        char gred='a';
        if(mark>=80 && mark<=100)
          gred = 'A';
      
        else if(mark>=70 && mark<80)
          gred = 'B';
      
        else if(mark>=60 && mark<70)
          gred = 'C';
      
        else if(mark>=50 && mark<60)
          gred = 'D';
      
        else if(mark>=40 && mark<50)
          gred = 'E';
      
        else if(mark>=0 && mark<40)
          gred = 'F';
        return gred;
      }
    
    }
    break;
    case 3:
    {
      cout<<"\n INSTRUCTIONS "<<endl;
      cout<<" ------------ "<<endl;
      cout<<"\n1) Enter the student name properly. "<<endl;
      cout<<"2) it is continue by the matrix number without exceed the maximum num of 10. "<<endl;
      cout<<"3) Next,enter the part and the course. "<<endl;
  
      cout<<"4) Then,select the place you want to use "<<endl;
  
      cout<<"\n\n THANK YOU!!!"<<endl;
      kembali = menuBack(back2Menu);
      system("cls");
    }
    
    {
      menu();
      select(num);
    }
    
    bool menuBack(bool back2Menu);
    
    char back;
    do
    {
      cout<<"\nBack to menu press 'M' or 'm'."<<endl;
      cin>>back;
      cout<<endl;
      if(back == 'M' || back == 'm')
      back2Menu = true;
    }
    while(back2Menu == false);
    return back2Menu;
  }
}

Notice, you only defined main, menu, and select functions, of all the ones you declared. You also have a case outside your switch (case 3).
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
rissa

rissa

    Newbie

  • Members
  • Pip
  • 4 posts
hmmm..i think my program have many error..but i already corret it...this is the latest one..but still have problem..
can anyone correct it...tq=)

#include<iostream>
#include<cstdlib>
using namespace std;


void pilih(char, char[][3], int, int);
void display(char[][3]);

void isi(char*, int, char, char [][3], int);
bool rules(char [][3]);
void decide(bool, int);
void menu();
bool select(char&);
bool menuBack(bool);

char grade( double mark);
char mark;

int main()
{
char num;
bool back;


do
{
menu();
back = select(num);
}
while(back == true);
system("pause");
}
void menu()
{
cout<<"\n------------WELCOME TO GRADE SYSTEM!!----------------"<<endl;
cout<<"---------------------------------------------------------"<<endl;
cout<<"| MENU |"<<endl;
cout<<"| |"<<endl;
cout<<"|1) ABOUT PROGRAMMERS 4) STUDENTS GRADE |"<<endl;
cout<<"| |"<<endl;
cout<<"|2) ABOUT GRADING 5) EXIT |"<<endl;
cout<<"| |"<<endl;
cout<<"|3) INSTRUCTIONS |"<<endl;
cout<<"| |"<<endl;
cout<<"| |"<<endl;
cout<<"| THANK YOU!!! :) |"<<endl;
cout<<"---------------------------------------------------------"<<endl;
}


bool select(char& num)
{
int nums;
bool back2Menu = false;
bool kembali = false;
cout<<"\nEnter your choice: ";
cin>>num;
cout<<endl;
system("cls");
nums = static_cast<int>(num);
nums -= 48;
if(nums>=1 && nums<=5)
{
switch (nums)
{
case 1:
{
cout<<"\n ABOUT PROGRAMMERS "<<endl;
cout<<" ----------------- "<<endl;
cout<<"\n1)AINURISSA 2009868978 EE2503A "<<endl;

kembali = menuBack(back2Menu);
system("cls");
}
break;
case 2:
{
int numStud;
int numTest;
int numQuiz;

cout<<"*******************************************"<<endl;
cout<<"---------Students grade---------------------"<<endl<<endl;
cout<<"Please enter the number of students' data : ";
cin>>numStud;
cout<<"Number of test:";
cin>>numTest;
cout<<"Number of quiz:";
cin>>numQuiz;

string nameStud[numStud];
string id[numStud];
string part[numStud];
string code[numStud];

double test;
double quiz;
double fin;
string gred[numStud];

for(int c = 0; c<numStud; c++)
{
cout<<"Enter student name:";
cin>>nameStud[c];
cout<<"Enter student ID:";
cin>>id[c];
cout<<"Enter part:";
cin>>part[c];
cout<<"Enter course code:";
cin>>code[c];
double totalT = 0;
for(int t=0; t<numTest; t++)
{
cout<<"Enter Test "<<(t+1)<<":";
cin>>test;
totalT += test;
}
double totalQ = 0;
for(int q=0; q<numQuiz; q++)
{
cout<<"Enter Quiz "<<(q+1)<<":";
cin>>quiz;
totalQ += quiz;
}

cout<<"Enter final examination mark : ";
cin>>fin;
fin*=(60/100);
double total = totalT+totalQ+fin;

cout<<"The mark you get: "<<total<<endl;
cout<<"The gred :\n"<<grade(total);
}

return 0;
}

char grade( double mark);
{
char gred='a';
if(mark>=80 && mark<=100)
gred = 'A';

else if(mark>=70 && mark<80)
gred = 'B';

else if(mark>=60 && mark<70)
gred = 'C';

else if(mark>=50 && mark<60)
gred = 'D';

else if(mark>=40 && mark<50)
gred = 'E';

else if(mark>=0 && mark<40)
gred = 'F';
return gred;
}


case 3:
{
cout<<"\n INSTRUCTIONS "<<endl;
cout<<" ------------ "<<endl;
cout<<"\n1) Enter the student name properly. "<<endl;
cout<<"2) it is continue by the matrix number without exceed the maximum num of 10. "<<endl;
cout<<"3) Next,enter the part and the course. "<<endl;

cout<<"4) Then,select the place you want to use "<<endl;

cout<<"\n\n THANK YOU!!!"<<endl;
break;
kembali = menuBack(back2Menu);
system("cls");
}

}


{
menu();
select(num);
}






bool menuBack(bool back2Menu);

char back;
do
{
cout<<"\nBack to menu press 'M' or 'm'."<<endl;
cin>>back;
cout<<endl;
if(back == 'M' || back == 'm')
back2Menu = true;
}
while(back2Menu == false);


return back2Menu;
}
}

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Step 1: use the # button to create code tags. If you refuse to do that much, it makes it MUCH harder for us to see what you have.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
rissa

rissa

    Newbie

  • Members
  • Pip
  • 4 posts
#include<iostream>
#include<cstdlib>
using namespace std;


void pilih(char, char[][3], int, int);
void display(char[][3]);

void isi(char*, int, char, char [][3], int);
bool rules(char [][3]);
void decide(bool, int);
void menu();
bool select(char&);
bool menuBack(bool);

char grade( double mark);
char mark;

int main()
{
char num;
bool back;


do
{
menu();
back = select(num);
}
while(back == true);
    system("pause");
}
void menu()
{
cout<<"\n------------WELCOME TO GRADE SYSTEM!!----------------"<<endl;
cout<<"---------------------------------------------------------"<<endl;
cout<<"| MENU |"<<endl;
cout<<"| |"<<endl;
cout<<"|1) ABOUT PROGRAMMERS 4) STUDENTS GRADE |"<<endl;
cout<<"| |"<<endl;
cout<<"|2) ABOUT GRADING 5) EXIT |"<<endl;
cout<<"| |"<<endl;
cout<<"|3) INSTRUCTIONS |"<<endl;
cout<<"| |"<<endl;
cout<<"| |"<<endl;
cout<<"| THANK YOU!!! :) |"<<endl;
cout<<"---------------------------------------------------------"<<endl;
}


bool select(char& num)
{
int nums;
bool back2Menu = false;
bool kembali = false;
cout<<"\nEnter your choice: ";
cin>>num;
cout<<endl;
system("cls");
nums = static_cast<int>(num);
nums -= 48;
if(nums>=1 && nums<=5)
{
switch (nums)
{
case 1:
   {
    cout<<"\n ABOUT PROGRAMMERS "<<endl;
    cout<<" ----------------- "<<endl;
    cout<<"\n1)AINURISSA 2009868978 EE2503A "<<endl;

kembali = menuBack(back2Menu);
system("cls");
}
break;
    case 2:
       {
int numStud;
int numTest;
int numQuiz;

cout<<"*******************************************"<<endl;
cout<<"---------Students grade---------------------"<<endl<<endl;
cout<<"Please enter the number of students' data : ";
cin>>numStud;
cout<<"Number of test:";
cin>>numTest;
cout<<"Number of quiz:";
cin>>numQuiz;

string nameStud[numStud];
string id[numStud];
string part[numStud];
string code[numStud];

double test;
double quiz;
double fin;
string gred[numStud];

for(int c = 0; c<numStud; c++)
{
cout<<"Enter student name:";
cin>>nameStud[c];
cout<<"Enter student ID:";
cin>>id[c];
cout<<"Enter part:";
cin>>part[c];
cout<<"Enter course code:";
cin>>code[c];
double totalT = 0;
for(int t=0; t<numTest; t++)
{
    cout<<"Enter Test "<<(t+1)<<":";
    cin>>test;
    totalT += test;
}
double totalQ = 0;
for(int q=0; q<numQuiz; q++)
{
    cout<<"Enter Quiz "<<(q+1)<<":";
    cin>>quiz;
    totalQ += quiz;
}

cout<<"Enter final examination mark : ";
cin>>fin;
fin*=(60/100);
double total = totalT+totalQ+fin;

cout<<"The mark you get: "<<total<<endl;
cout<<"The gred :\n"<<grade(total);
}

return 0;
}

char grade( double mark);
{
char gred='a';
if(mark>=80 && mark<=100)
    gred = 'A';

else if(mark>=70 && mark<80)
    gred = 'B';

else if(mark>=60 && mark<70)
    gred = 'C';

else if(mark>=50 && mark<60)
    gred = 'D';

else if(mark>=40 && mark<50)
    gred = 'E';

else if(mark>=0 && mark<40)
    gred = 'F';
return gred;
}


     case 3:
       {
    cout<<"\n INSTRUCTIONS "<<endl;
    cout<<" ------------ "<<endl;
    cout<<"\n1) Enter the student name properly. "<<endl;
    cout<<"2) it is continue by the matrix number without exceed the maximum num of 10. "<<endl;
    cout<<"3) Next,enter the part and the course. "<<endl;

    cout<<"4) Then,select the place you want to use "<<endl;

    cout<<"\n\n THANK YOU!!!"<<endl;
    break;
kembali = menuBack(back2Menu);
system("cls");
}

}


{
menu();
select(num);
}






bool menuBack(bool back2Menu);

char back;
do
{
cout<<"\nBack to menu press 'M' or 'm'."<<endl;
cin>>back;
cout<<endl;
if(back == 'M' || back == 'm')
back2Menu = true;
}
while(back2Menu == false);


return back2Menu;
}
}




#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Since you didn't reformat your code (see my earlier post), you probably still have open/close braces in the wrong places. I know it's easy to think of formatting as a nuisance, but it really does make code easier to read. As you continue learning, your code can grow to be thousands of lines long, and not having proper indentation makes it almost impossible to identify what's happening.

I would suggest you start with the code I had posted, and use that as the basis. I like using jEdit as an editor, because it makes indenting/unindenting blocks of code easy and simple.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
rissa

rissa

    Newbie

  • Members
  • Pip
  • 4 posts
okey thanks..but this is my program actually..
it can be run but i want to make some changing on my program.i want to put the option on my program.thats all.
#include <iostream>
#include <string>
using namespace std;

char grade( double mark);

int main()
{
int numStud;
int numTest;
int numQuiz;

cout<<"*******************************************"<<endl;
cout<<"---------Students grade---------------------"<<endl<<endl;
cout<<"Please enter the number of students' data : ";
cin>>numStud;
cout<<"Number of test:";
cin>>numTest;
cout<<"Number of quiz:";
cin>>numQuiz;

string nameStud[numStud];
string id[numStud];
string part[numStud];
string code[numStud];

double test;
double quiz;
double fin;
string gred[numStud];

for(int c = 0; c<numStud; c++)
{
cout<<"Enter student name:";
cin>>nameStud[c];
cout<<"Enter student ID:";
cin>>id[c];
cout<<"Enter part:";
cin>>part[c];
cout<<"Enter course code:";
cin>>code[c];
double totalT = 0;
for(int t=0; t<numTest; t++)
{
    cout<<"Enter Test "<<(t+1)<<":";
    cin>>test;
    totalT += test;
}
double totalQ = 0;
for(int q=0; q<numQuiz; q++)
{
    cout<<"Enter Quiz "<<(q+1)<<":";
    cin>>quiz;
    totalQ += quiz;
}

cout<<"Enter final examination mark : ";
cin>>fin;
fin*=(60/100);
double total = totalT+totalQ+fin;

cout<<"The mark you get: "<<total<<endl;
cout<<"The gred :\n"<<grade(total);
}

return 0;
}

char grade( double mark)
{
char gred='a';
if(mark>=80 && mark<=100)
    gred = 'A';

else if(mark>=70 && mark<80)
    gred = 'B';

else if(mark>=60 && mark<70)
    gred = 'C';

else if(mark>=50 && mark<60)
    gred = 'D';

else if(mark>=40 && mark<50)
    gred = 'E';

else if(mark>=0 && mark<40)
    gred = 'F';
return gred;
}









#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
I'm not clear what option you want to add.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users