Topic: C++ Help!  (Read 4060 times)

0 Members and 1 Guest are viewing this topic.

Iceman

  • Guest
C++ Help!
« on: May 10, 2004, 08:33:01 am »
Hey guys, I need some help with my C++ final. I'm trying to write a program that will store and edit statistics. Here it is.

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;

int main ()
{

int edit;
int wins;
int games;
int player;
int hits;
int at_bats;
int team_avg;
int MuellerAvg, OrtizAvg, RamirezAvg, DamonAvg, MillarAvg, VaritekAvg, BellhornAvg, ReeseAvg, KaplerAvg, CrespoAvg, BurksAvg, McCartyAvg, DaubachAvg, MirabelliAvg;


ofstream team;
ofstream BMueller;
ofstream DOrtiz;
ofstream MRamirez;
ofstream JDamon;
ofstream KMillar;
ofstream JVaritek;
ofstream MBellhorn;
ofstream PReese;
ofstream GKapler;
ofstream CCrespo;
ofstream EBurks;
ofstream DMcCarty;
ofstream BDaubach;
ofstream DMirabelli;



cout << "What will you be editing in your baseball teams statistics today?\n";
cout << "(1) Edit Team Win/Loss Record\n";
cout << "(2) View Team Win/Loss Record\n";
cout << "(3) Edit Individual Batting Averages\n";
cout << "(4) View Individual Batting Averages\n";

cin >> edit;
switch(edit)
{
case 1:
   ofstream team;
   cout << "Input the number of new wins since the last time you used this program.\n";
   cin >> wins;
   cout << "Input the number of new games since the last time you used this program.\n";
   cin >> games;
   team.open("TEAM.DAT",ios::out);
   if(team)
   {
      team << wins<< endl;
      team << games<< endl;
      team.close();
   }
   else
   {
      cout << "Error. Please contact developer.\n";
   }
   break;
case 2:
   {
   ifstream team;
   team.open("TEAM.DAT",ios::in);
   if(team)
   {
   do
   {   team >> wins;
      team >> games;
      team_avg = wins/games;
      cout.setf(ios::fixed);
      cout << "The RedSox win average is " <<setprecision(3) << team_avg << endl;
   }
   while(games !=0);

   
case 3:
   cout << "Which players statistics do you wish to edit?\n";
   cout << "(1) B Mueller\n";
   cout << "(2) D Ortiz\n";
   cout << "(3) M Ramirez\n";
   cout << "(4) J Damon\n";
   cout << "(5) K Millar\n";
   cout << "(6) J Varietk\n";
   cout << "(7) M Bellhorn\n";
   cout << "(8) P Reese\n";
   cout << "(9) G Kapler\n";
   cout << "(10) C Crespo\n";
   cout << "(11) E Burks\n";
   cout << "(12) D McCarty\n";
   cout << "(13) B Daubach\n";
   cout << "(14) D Mirabelli\n";
   cin >> player;
   switch(player)
   {
   case 1:
      ofstream BMueller;
      cout << "Input the number of hits for B Mueller now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for B Mueller now.\n";
      cin >> at_bats;
      BMueller.open("BMUELLER.DAT",ios::out);
      if(BMueller)
      {
         BMueller << hits << endl;
         BMueller << at_bats << endl;
         BMueller.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 2:
      ofstream DOrtiz;
      cout << "Input the number of hits for D Ortiz now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for D Ortiz now.\n";
      cin >> at_bats;
        DOrtiz.open("DORTIZ.DAT",ios::out);
      if(DOrtiz)
      {
         DOrtiz << hits << endl;
         DOrtiz << at_bats << endl;
         DOrtiz.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 3:
      ofstream MRamirez;
      cout << "Input the number of hits for M Ramirez now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for M Ramirez now.\n";
      cin >> at_bats;
      MRamirez.open("MRamirez.DAT",ios::out);
      if(MRamirez)
      {
         MRamirez << hits << endl;
         MRamirez << at_bats << endl;
         MRamirez.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 4:
      ofstream JDamon;
      cout << "Input the number of hits for J Damon now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for J Damon now.\n";
      cin >> at_bats;
      JDamon.open("JDAMON.DAT",ios::out);
      if(JDamon)
      {
         JDamon << hits << endl;
         JDamon << at_bats << endl;
         JDamon.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 5:
      ofstream KMillar;
      cout << "Input the number of hits for K Millar now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for K Millar now.\n";
      cin >> at_bats;
      KMillar.open("KMILLAR.DAT",ios::out);
      if(KMillar)
      {
         KMillar << hits << endl;
         KMillar << at_bats << endl;
         KMillar.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 6:
      ofstream JVaritek;
      cout << "Input the number of hits for J Varitek now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for J Varitek now.\n";
      cin >> at_bats;
      JVaritek.open("JVARITEK.DAT",ios::out);
      if(JVaritek)
      {
         JVaritek << hits << endl;
         JVaritek << at_bats << endl;
         JVaritek.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 7:
      ofstream MBellhorn;
      cout << "Input the number of hits for M Bellhorn now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for M Bellhorn now.\n";
      cin >> at_bats;
      MBellhorn.open("MBELLHORN.DAT",ios::out);
      if(MBellhorn)
      {
         MBellhorn << hits << endl;
         MBellhorn << at_bats << endl;
         MBellhorn.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 8:
      ofstream PReese;
      cout << "Input the number of hits for P Reese now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for P Reese now.\n";
      cin >> at_bats;
      PReese.open("PREESE.DAT",ios::out);
      if(PReese)
      {
         PReese << hits << endl;
         PReese << at_bats << endl;
         PReese.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 9:
      ofstream GKapler;
      cout << "Input the number of hits for G Kapler now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for G Kapler now.\n";
      cin >> at_bats;
      GKapler.open("GKAPLER.DAT",ios::out);
      if(GKapler)
      {
         GKapler << hits << endl;
         GKapler << at_bats << endl;
         GKapler.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 10:
      ofsteam CCrespo;
      cout << "Input the number of hits for C Crespo now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for C Crespo now.\n";
      cin >> at_bats;
      CCrespo.open("CCRESPO.DAT",ios::out);
      if(CCrespo)
      {
         CCrespo << hits << endl;
         CCrespo << at_bats << endl;
         CCrespo.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 11:
      ofstream EBurks;
      cout << "Input the number of hits for E Burks now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for E Burks now.\n";
      cin >> at_bats;
      EBurks.open("EBURKS.DAT",ios::out);
      if(EBurks)
      {
         EBurks << hits << endl;
         EBurks << at_bats << endl;
         EBurks.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 12:
      ofstream DMcCarty
      cout << "Input the number of hits for D McCarty now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for D McCarty now.\n";
      cin >> at_bats;
      DMcCarty.open("DMCCARTY.DAT",ios::out);
      if(DMcCarty)
      {
         DMcCarty << hits << endl;
         DMcCarty << at_bats << endl;
         DMcCarty.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 13:
      ofstream BDaubach
      cout << "Input the number of hits for B Daubach now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for B Daubach now.\n";
      cin >> at_bats;
      BDaubach.open("BDAUBACH.DAT",ios::out);
      if(BDaubach)
      {
         BDaubach << hits << endl;
         BDaubach << at_bats << endl;
         BDaubach.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 14:
      ofstream DMirabelli;
      cout << "Input the number of hits for D Mirabelli now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for D Mirabelli now.\n";
      cin >> at_bats;
      DMirabelli.open("DMIRABELLI.DAT",ios::out);
      if(DMirabelli)
      {
         DMirabelli << hits << endl;
         DMirabelli << at_bats << endl;
         DMirabelli.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;}
case 4:
   cout << "Which players statistics do you wish to view?\n";
   cout << "(1) B Mueller\n";
   cout << "(2) D Ortiz\n";
   cout << "(3) M Ramirez\n";
   cout << "(4) J Damon\n";
   cout << "(5) K Millar\n";
   cout << "(6) J Varietk\n";
   cout << "(7) M Bellhorn\n";
   cout << "(8) P Reese\n";
   cout << "(9) G Kapler\n";
   cout << "(10) C Crespo\n";
   cout << "(11) E Burks\n";
   cout << "(12) D McCarty\n";
   cout << "(13) B Daubach\n";
   cout << "(14) D Mirabelli\n";
   cin >> player;
   switch(player)
   case 1:
      if (BMueller)
      {
         cout.setf(ios::fixed);
         cout << "B Mueller's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         BMueller << hits;
         BMueller << at_bats;
         MuellerAvg = hits/at_bats;
         cout << MuellerAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (DOrtiz)
      {
         cout.setf(ios::fixed);
         cout << "D Ortiz's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         DOrtiz << hits;
         DOrtiz << at_bats;
         OrtizAvg = hits/at_bats;
         cout << OrtizAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (MRamirez)
      {
         cout.setf(ios::fixed);
         cout << "M Ramirez's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         MRamirez << hits;
         MRamirez << at_bats;
         RamirezAvg = hits/at_bats;
         cout << RamirezAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (JDamon)
      {
         cout.setf(ios::fixed);
         cout << "J Damon's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         JDamon << hits;
         JDamon << at_bats;
         DamonAvg = hits/at_bats;
         cout << DamonAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (KMillar)
      {
         cout.setf(ios::fixed);
         cout << "K Millar's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         KMillar << hits;
         KMillar << at_bats;
         MillarAvg = hits/at_bats;
         cout << MuellerAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (JVaritek)
      {
         cout.setf(ios::fixed);
         cout << "J Varitek's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         JVaritek << hits;
         JVaritek << at_bats;
         VaritekAvg = hits/at_bats;
         cout << MuellerAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (MBellhorn)
      {
         cout.setf(ios::fixed);
         cout << "M Bellhorn's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         MBellhorn << hits;
         MBellhorn << at_bats;
         BellhornAvg = hits/at_bats;
         cout << BellhornAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (PReese)
      {
         cout.setf(ios::fixed);
         cout << "P Reese's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         PReese << hits;
         PReese << at_bats;
         ReeseAvg = hits/at_bats;
         cout << ReeseAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (GKapler)
      {
         cout.setf(ios::fixed);
         cout << "G Kapler's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         GKapler << hits;
         GKapler << at_bats;
         KaplerAvg = hits/at_bats;
         cout << KaplerAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (CCrespo)
      {
         cout.setf(ios::fixed);
         cout << "C Crespo's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         CCrespo << hits;
         CCrespo << at_bats;
         CrespoAvg = hits/at_bats;
         cout << CrespoAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (EBurks)
      {
         cout.setf(ios::fixed);
         cout << "E Burks's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         EBurks << hits;
         EBurks << at_bats;
         BurksAvg = hits/at_bats;
         cout << BurksAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (DMcCarty)
      {
         cout.setf(ios::fixed);
         cout << "D McCarty's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         DMcCarty << hits;
         DMcCarty << at_bats;
         McCartyAvg = hits/at_bats;
         cout << McCartyAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (BDaubach)
      {
         cout.setf(ios::fixed);
         cout << "B Daubach's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         BDaubach << hits;
         BDaubach << at_bats;
         DaubachAvg = hits/at_bats;
         cout << DaubachAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (DMirabelli)
      {
         cout.setf(ios::fixed);
         cout << "D Mirabelli's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         DMirabelli << hits;
         DMirabelli << at_bats;
         MirabelliAvg = hits/at_bats;
         cout << MirabelliAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }


}
}
}
return 0;
}  

Iceman

  • Guest
Re: C++ Help!
« Reply #1 on: May 10, 2004, 08:33:43 am »
And here is the error report;


:\C++\project.cpp(68) : error C2360: initialization of 'team' is skipped by 'case' label
        E:\C++\project.cpp(51) : see declaration of 'team'
E:\C++\project.cpp(84) : error C2360: initialization of 'team' is skipped by 'case' label
        E:\C++\project.cpp(70) : see declaration of 'team'
E:\C++\project.cpp(84) : error C2360: initialization of 'team' is skipped by 'case' label
        E:\C++\project.cpp(51) : see declaration of 'team'
E:\C++\project.cpp(121) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(139) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(139) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(157) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(157) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(157) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(175) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(175) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(175) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(175) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(193) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(193) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(193) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(193) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(193) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(211) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(211) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(211) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(211) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(211) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(211) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(229) : error C2360: initialization of 'MBellhorn' is skipped by 'case' label
        E:\C++\project.cpp(212) : see declaration of 'MBellhorn'
E:\C++\project.cpp(229) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(229) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(229) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(229) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(229) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(229) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(247) : error C2360: initialization of 'PReese' is skipped by 'case' label
        E:\C++\project.cpp(230) : see declaration of 'PReese'
E:\C++\project.cpp(247) : error C2360: initialization of 'MBellhorn' is skipped by 'case' label
        E:\C++\project.cpp(212) : see declaration of 'MBellhorn'
E:\C++\project.cpp(247) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(247) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(247) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(247) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(247) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(247) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(265) : error C2360: initialization of 'GKapler' is skipped by 'case' label
        E:\C++\project.cpp(248) : see declaration of 'GKapler'
E:\C++\project.cpp(265) : error C2360: initialization of 'PReese' is skipped by 'case' label
        E:\C++\project.cpp(230) : see declaration of 'PReese'
E:\C++\project.cpp(265) : error C2360: initialization of 'MBellhorn' is skipped by 'case' label
        E:\C++\project.cpp(212) : see declaration of 'MBellhorn'
E:\C++\project.cpp(265) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(265) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(265) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(265) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(265) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(265) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(266) : error C2065: 'ofsteam' : undeclared identifier
E:\C++\project.cpp(266) : error C2146: syntax error : missing ';' before identifier 'CCrespo'
E:\C++\project.cpp(283) : error C2360: initialization of 'GKapler' is skipped by 'case' label
        E:\C++\project.cpp(248) : see declaration of 'GKapler'
E:\C++\project.cpp(283) : error C2360: initialization of 'PReese' is skipped by 'case' label
        E:\C++\project.cpp(230) : see declaration of 'PReese'
E:\C++\project.cpp(283) : error C2360: initialization of 'MBellhorn' is skipped by 'case' label
        E:\C++\project.cpp(212) : see declaration of 'MBellhorn'
E:\C++\project.cpp(283) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(283) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(283) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(283) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(283) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(283) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(301) : error C2360: initialization of 'EBurks' is skipped by 'case' label
        E:\C++\project.cpp(284) : see declaration of 'EBurks'
E:\C++\project.cpp(301) : error C2360: initialization of 'GKapler' is skipped by 'case' label
        E:\C++\project.cpp(248) : see declaration of 'GKapler'
E:\C++\project.cpp(301) : error C2360: initialization of 'PReese' is skipped by 'case' label
        E:\C++\project.cpp(230) : see declaration of 'PReese'
E:\C++\project.cpp(301) : error C2360: initialization of 'MBellhorn' is skipped by 'case' label
        E:\C++\project.cpp(212) : see declaration of 'MBellhorn'
E:\C++\project.cpp(301) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(301) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(301) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(301) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(301) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(301) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(303) : error C2146: syntax error : missing ';' before identifier 'cout'
E:\C++\project.cpp(319) : error C2360: initialization of 'DMcCarty' is skipped by 'case' label
        E:\C++\project.cpp(303) : see declaration of 'DMcCarty'
E:\C++\project.cpp(319) : error C2360: initialization of 'EBurks' is skipped by 'case' label
        E:\C++\project.cpp(284) : see declaration of 'EBurks'
E:\C++\project.cpp(319) : error C2360: initialization of 'GKapler' is skipped by 'case' label
        E:\C++\project.cpp(248) : see declaration of 'GKapler'
E:\C++\project.cpp(319) : error C2360: initialization of 'PReese' is skipped by 'case' label
        E:\C++\project.cpp(230) : see declaration of 'PReese'
E:\C++\project.cpp(319) : error C2360: initialization of 'MBellhorn' is skipped by 'case' label
        E:\C++\project.cpp(212) : see declaration of 'MBellhorn'
E:\C++\project.cpp(319) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(319) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(319) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(319) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(319) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(319) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(321) : error C2146: syntax error : missing ';' before identifier 'cout'
E:\C++\project.cpp(337) : error C2360: initialization of 'BDaubach' is skipped by 'case' label
        E:\C++\project.cpp(321) : see declaration of 'BDaubach'
E:\C++\project.cpp(337) : error C2360: initialization of 'DMcCarty' is skipped by 'case' label
        E:\C++\project.cpp(303) : see declaration of 'DMcCarty'
E:\C++\project.cpp(337) : error C2360: initialization of 'EBurks' is skipped by 'case' label
        E:\C++\project.cpp(284) : see declaration of 'EBurks'
E:\C++\project.cpp(337) : error C2360: initialization of 'GKapler' is skipped by 'case' label
        E:\C++\project.cpp(248) : see declaration of 'GKapler'
E:\C++\project.cpp(337) : error C2360: initialization of 'PReese' is skipped by 'case' label
        E:\C++\project.cpp(230) : see declaration of 'PReese'
E:\C++\project.cpp(337) : error C2360: initialization of 'MBellhorn' is skipped by 'case' label
        E:\C++\project.cpp(212) : see declaration of 'MBellhorn'
E:\C++\project.cpp(337) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(337) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(337) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(337) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(337) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(337) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(339) : error C2146: syntax error : missing ';' before identifier 'cout'
E:\C++\project.cpp(355) : error C2360: initialization of 'team' is skipped by 'case' label
        E:\C++\project.cpp(70) : see declaration of 'team'
E:\C++\project.cpp(355) : error C2360: initialization of 'team' is skipped by 'case' label
        E:\C++\project.cpp(51) : see declaration of 'team'
Error executing cl.exe.

project.exe - 97 error(s), 0 warning(s)


 

David Ferrell

  • Guest
Re: C++ Help!
« Reply #2 on: May 10, 2004, 09:15:47 am »
Try putting the contents of your case statements inside brackets:

switch( color )
{
case blue:
{
//code
}
break;
case red:
{
//code
}
break;
default:
{
//code
}
}
//end

That should clear up the errors.

Thanks,

Dave
« Last Edit: May 10, 2004, 09:17:05 am by David Ferrell »

Iceman

  • Guest
Re: C++ Help!
« Reply #3 on: May 10, 2004, 01:41:13 pm »
I'll try it tomorrow, no C++ at home. Thanks!

Khalee

  • Guest
Re: C++ Help!
« Reply #4 on: May 10, 2004, 01:49:11 pm »
Damn whatever happend to   if, and ,or, and goto and line 10 line 20 line 30. Arn't thoes commands still use.

Iceman

  • Guest
Re: C++ Help!
« Reply #5 on: May 10, 2004, 01:52:35 pm »
I've used goto once, and my friend called me the spawn of satan. So yeah, I guess they're gone. But then again, this is an intro course, I'm sure there are uses for it.  

TalonClaw

  • Guest
Re: C++ Help!
« Reply #6 on: May 10, 2004, 02:06:55 pm »
Quote:

Damn whatever happend to   if, and ,or, and goto and line 10 line 20 line 30. Arn't thoes commands still use.  




goto is considered to be very poor programming.  
 
« Last Edit: December 31, 1969, 06:00:00 pm by TalonClaw »

TalonClaw

  • Guest
Re: C++ Help!
« Reply #7 on: May 10, 2004, 02:10:41 pm »
Quote:

I've used goto once, and my friend called me the spawn of satan. So yeah, I guess they're gone. But then again, this is an intro course, I'm sure there are uses for it.  




Your program would be a lot cleaner and easier to read if you split it up into sub routines.  The main loop is suppose to be as small as possible.  You could also cut down on a lot of repetative code.

For instance you are saying case player1 do this, case player2 do that.  You could make a subroutine and pass that info to it and only write that code once.
« Last Edit: December 31, 1969, 06:00:00 pm by TalonClaw »

Toasty0

  • Guest
Re: C++ Help!
« Reply #8 on: May 10, 2004, 02:50:06 pm »
Quote:

Quote:

Damn whatever happend to   if, and ,or, and goto and line 10 line 20 line 30. Arn't thoes commands still use.  




goto is considered to be very poor programming.  
 




With the exception of the designer himself this seems to a widely held belief.

http://www.research.att.com/~bs/C++.html

He also doesn't see OOP as the end all be all of design either. But that is another rant for another time.

Best,
Jerry  

Iceman

  • Guest
Re: C++ Help!
« Reply #9 on: May 10, 2004, 03:46:45 pm »
I still dont understand why goto is 'bad programming.' and I'm unclear what you mean by putting it all in a subroutine.  I think I get it, but I'm not sure.

Towelie

  • Guest
Re: C++ Help!
« Reply #10 on: May 10, 2004, 05:59:20 pm »
Quote:

I still dont understand why goto is 'bad programming.' and I'm unclear what you mean by putting it all in a subroutine.  I think I get it, but I'm not sure.  




  Well, I never got into C++, but I understand the problem. Instead of retyping the same code over and over, create a sub once and just use it instead of rewriting the same code. If you find yourself retyping almost the same code over and over, chances are you could just write it once and use it as needed. This has the added benefit of compacting the code, and automatically it will run more effienciently and faster. And as for the GOTO commands, break down the processes that the system must follow everytime it hits a goto command, and then you will see the problems with it. There are more effecient ways, unless of course you writing software for the goverment  

***EDIT***

  Like I said, I never really got too deep into C++, but these...

case 1:
ofstream BMueller;
cout << "Input the number of hits for B Mueller now.\n";
cin >> hits;
cout << "Input the number of at-bats for B Mueller now.\n";
cin >> at_bats;
BMueller.open("BMUELLER.DAT",ios::out);
if(BMueller)
{
BMueller << hits << endl;
BMueller << at_bats << endl;
BMueller.close();
}
else
{
cout << "Error. Please contact the developer.\n";
}
break;
case 2:
ofstream DOrtiz;
cout << "Input the number of hits for D Ortiz now.\n";
cin >> hits;
cout << "Input the number of at-bats for D Ortiz now.\n";
cin >> at_bats;
DOrtiz.open("DORTIZ.DAT",ios::out);
if(DOrtiz)
{
DOrtiz << hits << endl;
DOrtiz << at_bats << endl;
DOrtiz.close();
}
else
{
cout << "Error. Please contact the developer.\n";
}
break;
 

   ...can be reduced down to one sub, and just use it as needed. But unless things have changed, those are covered later in the course. Remember one rule that I had burned into me, the smaller the code the better.

     
« Last Edit: May 10, 2004, 06:05:36 pm by Towelie »

Intrepid-XC

  • Guest
Re: C++ Help!
« Reply #11 on: May 10, 2004, 07:10:06 pm »
ITs about functions.  Rather than type the same code over and over again, simply make a function that does a certain task.  Then all you do is call that function and pass through the variables.  

Its a difficult concept for a beginner (at least it was in my beginning programming class) but once I got the concept it made my code much more simple.    

Iceman

  • Guest
Re: C++ Help!
« Reply #12 on: May 10, 2004, 08:26:02 pm »
Its not so much the concept as the implementation. I don't have the time to learn a new idea right now AND finish this. So I think anyways.  

TalonClaw

  • Guest
Re: C++ Help!
« Reply #13 on: May 11, 2004, 08:42:55 am »
Quote:

Its not so much the concept as the implementation. I don't have the time to learn a new idea right now AND finish this. So I think anyways.  




Towelie is right.  If you examine the code where you are doing the same thing for each player the same code is typed in over and over again.  You could make a function with this code and pass in the player name.  The function would then do the tasks needed for the player passed into the function.

But don't sweat it. Just do the best you can for now and get it done.  The good stuff can come later and you will see how to make your code more efficient.  

Iceman

  • Guest
C++ Help!
« Reply #14 on: May 10, 2004, 08:33:01 am »
Hey guys, I need some help with my C++ final. I'm trying to write a program that will store and edit statistics. Here it is.

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;

int main ()
{

int edit;
int wins;
int games;
int player;
int hits;
int at_bats;
int team_avg;
int MuellerAvg, OrtizAvg, RamirezAvg, DamonAvg, MillarAvg, VaritekAvg, BellhornAvg, ReeseAvg, KaplerAvg, CrespoAvg, BurksAvg, McCartyAvg, DaubachAvg, MirabelliAvg;


ofstream team;
ofstream BMueller;
ofstream DOrtiz;
ofstream MRamirez;
ofstream JDamon;
ofstream KMillar;
ofstream JVaritek;
ofstream MBellhorn;
ofstream PReese;
ofstream GKapler;
ofstream CCrespo;
ofstream EBurks;
ofstream DMcCarty;
ofstream BDaubach;
ofstream DMirabelli;



cout << "What will you be editing in your baseball teams statistics today?\n";
cout << "(1) Edit Team Win/Loss Record\n";
cout << "(2) View Team Win/Loss Record\n";
cout << "(3) Edit Individual Batting Averages\n";
cout << "(4) View Individual Batting Averages\n";

cin >> edit;
switch(edit)
{
case 1:
   ofstream team;
   cout << "Input the number of new wins since the last time you used this program.\n";
   cin >> wins;
   cout << "Input the number of new games since the last time you used this program.\n";
   cin >> games;
   team.open("TEAM.DAT",ios::out);
   if(team)
   {
      team << wins<< endl;
      team << games<< endl;
      team.close();
   }
   else
   {
      cout << "Error. Please contact developer.\n";
   }
   break;
case 2:
   {
   ifstream team;
   team.open("TEAM.DAT",ios::in);
   if(team)
   {
   do
   {   team >> wins;
      team >> games;
      team_avg = wins/games;
      cout.setf(ios::fixed);
      cout << "The RedSox win average is " <<setprecision(3) << team_avg << endl;
   }
   while(games !=0);

   
case 3:
   cout << "Which players statistics do you wish to edit?\n";
   cout << "(1) B Mueller\n";
   cout << "(2) D Ortiz\n";
   cout << "(3) M Ramirez\n";
   cout << "(4) J Damon\n";
   cout << "(5) K Millar\n";
   cout << "(6) J Varietk\n";
   cout << "(7) M Bellhorn\n";
   cout << "(8) P Reese\n";
   cout << "(9) G Kapler\n";
   cout << "(10) C Crespo\n";
   cout << "(11) E Burks\n";
   cout << "(12) D McCarty\n";
   cout << "(13) B Daubach\n";
   cout << "(14) D Mirabelli\n";
   cin >> player;
   switch(player)
   {
   case 1:
      ofstream BMueller;
      cout << "Input the number of hits for B Mueller now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for B Mueller now.\n";
      cin >> at_bats;
      BMueller.open("BMUELLER.DAT",ios::out);
      if(BMueller)
      {
         BMueller << hits << endl;
         BMueller << at_bats << endl;
         BMueller.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 2:
      ofstream DOrtiz;
      cout << "Input the number of hits for D Ortiz now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for D Ortiz now.\n";
      cin >> at_bats;
        DOrtiz.open("DORTIZ.DAT",ios::out);
      if(DOrtiz)
      {
         DOrtiz << hits << endl;
         DOrtiz << at_bats << endl;
         DOrtiz.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 3:
      ofstream MRamirez;
      cout << "Input the number of hits for M Ramirez now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for M Ramirez now.\n";
      cin >> at_bats;
      MRamirez.open("MRamirez.DAT",ios::out);
      if(MRamirez)
      {
         MRamirez << hits << endl;
         MRamirez << at_bats << endl;
         MRamirez.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 4:
      ofstream JDamon;
      cout << "Input the number of hits for J Damon now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for J Damon now.\n";
      cin >> at_bats;
      JDamon.open("JDAMON.DAT",ios::out);
      if(JDamon)
      {
         JDamon << hits << endl;
         JDamon << at_bats << endl;
         JDamon.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 5:
      ofstream KMillar;
      cout << "Input the number of hits for K Millar now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for K Millar now.\n";
      cin >> at_bats;
      KMillar.open("KMILLAR.DAT",ios::out);
      if(KMillar)
      {
         KMillar << hits << endl;
         KMillar << at_bats << endl;
         KMillar.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 6:
      ofstream JVaritek;
      cout << "Input the number of hits for J Varitek now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for J Varitek now.\n";
      cin >> at_bats;
      JVaritek.open("JVARITEK.DAT",ios::out);
      if(JVaritek)
      {
         JVaritek << hits << endl;
         JVaritek << at_bats << endl;
         JVaritek.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 7:
      ofstream MBellhorn;
      cout << "Input the number of hits for M Bellhorn now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for M Bellhorn now.\n";
      cin >> at_bats;
      MBellhorn.open("MBELLHORN.DAT",ios::out);
      if(MBellhorn)
      {
         MBellhorn << hits << endl;
         MBellhorn << at_bats << endl;
         MBellhorn.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 8:
      ofstream PReese;
      cout << "Input the number of hits for P Reese now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for P Reese now.\n";
      cin >> at_bats;
      PReese.open("PREESE.DAT",ios::out);
      if(PReese)
      {
         PReese << hits << endl;
         PReese << at_bats << endl;
         PReese.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 9:
      ofstream GKapler;
      cout << "Input the number of hits for G Kapler now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for G Kapler now.\n";
      cin >> at_bats;
      GKapler.open("GKAPLER.DAT",ios::out);
      if(GKapler)
      {
         GKapler << hits << endl;
         GKapler << at_bats << endl;
         GKapler.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 10:
      ofsteam CCrespo;
      cout << "Input the number of hits for C Crespo now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for C Crespo now.\n";
      cin >> at_bats;
      CCrespo.open("CCRESPO.DAT",ios::out);
      if(CCrespo)
      {
         CCrespo << hits << endl;
         CCrespo << at_bats << endl;
         CCrespo.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 11:
      ofstream EBurks;
      cout << "Input the number of hits for E Burks now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for E Burks now.\n";
      cin >> at_bats;
      EBurks.open("EBURKS.DAT",ios::out);
      if(EBurks)
      {
         EBurks << hits << endl;
         EBurks << at_bats << endl;
         EBurks.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 12:
      ofstream DMcCarty
      cout << "Input the number of hits for D McCarty now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for D McCarty now.\n";
      cin >> at_bats;
      DMcCarty.open("DMCCARTY.DAT",ios::out);
      if(DMcCarty)
      {
         DMcCarty << hits << endl;
         DMcCarty << at_bats << endl;
         DMcCarty.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 13:
      ofstream BDaubach
      cout << "Input the number of hits for B Daubach now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for B Daubach now.\n";
      cin >> at_bats;
      BDaubach.open("BDAUBACH.DAT",ios::out);
      if(BDaubach)
      {
         BDaubach << hits << endl;
         BDaubach << at_bats << endl;
         BDaubach.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;
   case 14:
      ofstream DMirabelli;
      cout << "Input the number of hits for D Mirabelli now.\n";
      cin >> hits;
      cout << "Input the number of at-bats for D Mirabelli now.\n";
      cin >> at_bats;
      DMirabelli.open("DMIRABELLI.DAT",ios::out);
      if(DMirabelli)
      {
         DMirabelli << hits << endl;
         DMirabelli << at_bats << endl;
         DMirabelli.close();
      }
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
      break;}
case 4:
   cout << "Which players statistics do you wish to view?\n";
   cout << "(1) B Mueller\n";
   cout << "(2) D Ortiz\n";
   cout << "(3) M Ramirez\n";
   cout << "(4) J Damon\n";
   cout << "(5) K Millar\n";
   cout << "(6) J Varietk\n";
   cout << "(7) M Bellhorn\n";
   cout << "(8) P Reese\n";
   cout << "(9) G Kapler\n";
   cout << "(10) C Crespo\n";
   cout << "(11) E Burks\n";
   cout << "(12) D McCarty\n";
   cout << "(13) B Daubach\n";
   cout << "(14) D Mirabelli\n";
   cin >> player;
   switch(player)
   case 1:
      if (BMueller)
      {
         cout.setf(ios::fixed);
         cout << "B Mueller's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         BMueller << hits;
         BMueller << at_bats;
         MuellerAvg = hits/at_bats;
         cout << MuellerAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (DOrtiz)
      {
         cout.setf(ios::fixed);
         cout << "D Ortiz's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         DOrtiz << hits;
         DOrtiz << at_bats;
         OrtizAvg = hits/at_bats;
         cout << OrtizAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (MRamirez)
      {
         cout.setf(ios::fixed);
         cout << "M Ramirez's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         MRamirez << hits;
         MRamirez << at_bats;
         RamirezAvg = hits/at_bats;
         cout << RamirezAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (JDamon)
      {
         cout.setf(ios::fixed);
         cout << "J Damon's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         JDamon << hits;
         JDamon << at_bats;
         DamonAvg = hits/at_bats;
         cout << DamonAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (KMillar)
      {
         cout.setf(ios::fixed);
         cout << "K Millar's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         KMillar << hits;
         KMillar << at_bats;
         MillarAvg = hits/at_bats;
         cout << MuellerAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (JVaritek)
      {
         cout.setf(ios::fixed);
         cout << "J Varitek's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         JVaritek << hits;
         JVaritek << at_bats;
         VaritekAvg = hits/at_bats;
         cout << MuellerAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (MBellhorn)
      {
         cout.setf(ios::fixed);
         cout << "M Bellhorn's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         MBellhorn << hits;
         MBellhorn << at_bats;
         BellhornAvg = hits/at_bats;
         cout << BellhornAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (PReese)
      {
         cout.setf(ios::fixed);
         cout << "P Reese's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         PReese << hits;
         PReese << at_bats;
         ReeseAvg = hits/at_bats;
         cout << ReeseAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (GKapler)
      {
         cout.setf(ios::fixed);
         cout << "G Kapler's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         GKapler << hits;
         GKapler << at_bats;
         KaplerAvg = hits/at_bats;
         cout << KaplerAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (CCrespo)
      {
         cout.setf(ios::fixed);
         cout << "C Crespo's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         CCrespo << hits;
         CCrespo << at_bats;
         CrespoAvg = hits/at_bats;
         cout << CrespoAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (EBurks)
      {
         cout.setf(ios::fixed);
         cout << "E Burks's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         EBurks << hits;
         EBurks << at_bats;
         BurksAvg = hits/at_bats;
         cout << BurksAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (DMcCarty)
      {
         cout.setf(ios::fixed);
         cout << "D McCarty's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         DMcCarty << hits;
         DMcCarty << at_bats;
         McCartyAvg = hits/at_bats;
         cout << McCartyAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (BDaubach)
      {
         cout.setf(ios::fixed);
         cout << "B Daubach's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         BDaubach << hits;
         BDaubach << at_bats;
         DaubachAvg = hits/at_bats;
         cout << DaubachAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }
   if (DMirabelli)
      {
         cout.setf(ios::fixed);
         cout << "D Mirabelli's batting average is as follows:\n";
         cout << setprecision(3);

      do
      {
         DMirabelli << hits;
         DMirabelli << at_bats;
         MirabelliAvg = hits/at_bats;
         cout << MirabelliAvg <<endl;
      }
      
      while(hits != 0);}
      else
      {
         cout << "Error. Please contact the developer.\n";
      }


}
}
}
return 0;
}  

Iceman

  • Guest
Re: C++ Help!
« Reply #15 on: May 10, 2004, 08:33:43 am »
And here is the error report;


:\C++\project.cpp(68) : error C2360: initialization of 'team' is skipped by 'case' label
        E:\C++\project.cpp(51) : see declaration of 'team'
E:\C++\project.cpp(84) : error C2360: initialization of 'team' is skipped by 'case' label
        E:\C++\project.cpp(70) : see declaration of 'team'
E:\C++\project.cpp(84) : error C2360: initialization of 'team' is skipped by 'case' label
        E:\C++\project.cpp(51) : see declaration of 'team'
E:\C++\project.cpp(121) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(139) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(139) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(157) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(157) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(157) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(175) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(175) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(175) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(175) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(193) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(193) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(193) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(193) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(193) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(211) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(211) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(211) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(211) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(211) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(211) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(229) : error C2360: initialization of 'MBellhorn' is skipped by 'case' label
        E:\C++\project.cpp(212) : see declaration of 'MBellhorn'
E:\C++\project.cpp(229) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(229) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(229) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(229) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(229) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(229) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(247) : error C2360: initialization of 'PReese' is skipped by 'case' label
        E:\C++\project.cpp(230) : see declaration of 'PReese'
E:\C++\project.cpp(247) : error C2360: initialization of 'MBellhorn' is skipped by 'case' label
        E:\C++\project.cpp(212) : see declaration of 'MBellhorn'
E:\C++\project.cpp(247) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(247) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(247) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(247) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(247) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(247) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(265) : error C2360: initialization of 'GKapler' is skipped by 'case' label
        E:\C++\project.cpp(248) : see declaration of 'GKapler'
E:\C++\project.cpp(265) : error C2360: initialization of 'PReese' is skipped by 'case' label
        E:\C++\project.cpp(230) : see declaration of 'PReese'
E:\C++\project.cpp(265) : error C2360: initialization of 'MBellhorn' is skipped by 'case' label
        E:\C++\project.cpp(212) : see declaration of 'MBellhorn'
E:\C++\project.cpp(265) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(265) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(265) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(265) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(265) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(265) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(266) : error C2065: 'ofsteam' : undeclared identifier
E:\C++\project.cpp(266) : error C2146: syntax error : missing ';' before identifier 'CCrespo'
E:\C++\project.cpp(283) : error C2360: initialization of 'GKapler' is skipped by 'case' label
        E:\C++\project.cpp(248) : see declaration of 'GKapler'
E:\C++\project.cpp(283) : error C2360: initialization of 'PReese' is skipped by 'case' label
        E:\C++\project.cpp(230) : see declaration of 'PReese'
E:\C++\project.cpp(283) : error C2360: initialization of 'MBellhorn' is skipped by 'case' label
        E:\C++\project.cpp(212) : see declaration of 'MBellhorn'
E:\C++\project.cpp(283) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(283) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(283) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(283) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(283) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(283) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(301) : error C2360: initialization of 'EBurks' is skipped by 'case' label
        E:\C++\project.cpp(284) : see declaration of 'EBurks'
E:\C++\project.cpp(301) : error C2360: initialization of 'GKapler' is skipped by 'case' label
        E:\C++\project.cpp(248) : see declaration of 'GKapler'
E:\C++\project.cpp(301) : error C2360: initialization of 'PReese' is skipped by 'case' label
        E:\C++\project.cpp(230) : see declaration of 'PReese'
E:\C++\project.cpp(301) : error C2360: initialization of 'MBellhorn' is skipped by 'case' label
        E:\C++\project.cpp(212) : see declaration of 'MBellhorn'
E:\C++\project.cpp(301) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(301) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(301) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(301) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(301) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(301) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(303) : error C2146: syntax error : missing ';' before identifier 'cout'
E:\C++\project.cpp(319) : error C2360: initialization of 'DMcCarty' is skipped by 'case' label
        E:\C++\project.cpp(303) : see declaration of 'DMcCarty'
E:\C++\project.cpp(319) : error C2360: initialization of 'EBurks' is skipped by 'case' label
        E:\C++\project.cpp(284) : see declaration of 'EBurks'
E:\C++\project.cpp(319) : error C2360: initialization of 'GKapler' is skipped by 'case' label
        E:\C++\project.cpp(248) : see declaration of 'GKapler'
E:\C++\project.cpp(319) : error C2360: initialization of 'PReese' is skipped by 'case' label
        E:\C++\project.cpp(230) : see declaration of 'PReese'
E:\C++\project.cpp(319) : error C2360: initialization of 'MBellhorn' is skipped by 'case' label
        E:\C++\project.cpp(212) : see declaration of 'MBellhorn'
E:\C++\project.cpp(319) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(319) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(319) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(319) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(319) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(319) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(321) : error C2146: syntax error : missing ';' before identifier 'cout'
E:\C++\project.cpp(337) : error C2360: initialization of 'BDaubach' is skipped by 'case' label
        E:\C++\project.cpp(321) : see declaration of 'BDaubach'
E:\C++\project.cpp(337) : error C2360: initialization of 'DMcCarty' is skipped by 'case' label
        E:\C++\project.cpp(303) : see declaration of 'DMcCarty'
E:\C++\project.cpp(337) : error C2360: initialization of 'EBurks' is skipped by 'case' label
        E:\C++\project.cpp(284) : see declaration of 'EBurks'
E:\C++\project.cpp(337) : error C2360: initialization of 'GKapler' is skipped by 'case' label
        E:\C++\project.cpp(248) : see declaration of 'GKapler'
E:\C++\project.cpp(337) : error C2360: initialization of 'PReese' is skipped by 'case' label
        E:\C++\project.cpp(230) : see declaration of 'PReese'
E:\C++\project.cpp(337) : error C2360: initialization of 'MBellhorn' is skipped by 'case' label
        E:\C++\project.cpp(212) : see declaration of 'MBellhorn'
E:\C++\project.cpp(337) : error C2360: initialization of 'JVaritek' is skipped by 'case' label
        E:\C++\project.cpp(194) : see declaration of 'JVaritek'
E:\C++\project.cpp(337) : error C2360: initialization of 'KMillar' is skipped by 'case' label
        E:\C++\project.cpp(176) : see declaration of 'KMillar'
E:\C++\project.cpp(337) : error C2360: initialization of 'JDamon' is skipped by 'case' label
        E:\C++\project.cpp(158) : see declaration of 'JDamon'
E:\C++\project.cpp(337) : error C2360: initialization of 'MRamirez' is skipped by 'case' label
        E:\C++\project.cpp(140) : see declaration of 'MRamirez'
E:\C++\project.cpp(337) : error C2360: initialization of 'DOrtiz' is skipped by 'case' label
        E:\C++\project.cpp(122) : see declaration of 'DOrtiz'
E:\C++\project.cpp(337) : error C2360: initialization of 'BMueller' is skipped by 'case' label
        E:\C++\project.cpp(104) : see declaration of 'BMueller'
E:\C++\project.cpp(339) : error C2146: syntax error : missing ';' before identifier 'cout'
E:\C++\project.cpp(355) : error C2360: initialization of 'team' is skipped by 'case' label
        E:\C++\project.cpp(70) : see declaration of 'team'
E:\C++\project.cpp(355) : error C2360: initialization of 'team' is skipped by 'case' label
        E:\C++\project.cpp(51) : see declaration of 'team'
Error executing cl.exe.

project.exe - 97 error(s), 0 warning(s)


 

David Ferrell

  • Guest
Re: C++ Help!
« Reply #16 on: May 10, 2004, 09:15:47 am »
Try putting the contents of your case statements inside brackets:

switch( color )
{
case blue:
{
//code
}
break;
case red:
{
//code
}
break;
default:
{
//code
}
}
//end

That should clear up the errors.

Thanks,

Dave
« Last Edit: May 10, 2004, 09:17:05 am by David Ferrell »

Iceman

  • Guest
Re: C++ Help!
« Reply #17 on: May 10, 2004, 01:41:13 pm »
I'll try it tomorrow, no C++ at home. Thanks!

Khalee

  • Guest
Re: C++ Help!
« Reply #18 on: May 10, 2004, 01:49:11 pm »
Damn whatever happend to   if, and ,or, and goto and line 10 line 20 line 30. Arn't thoes commands still use.

Iceman

  • Guest
Re: C++ Help!
« Reply #19 on: May 10, 2004, 01:52:35 pm »
I've used goto once, and my friend called me the spawn of satan. So yeah, I guess they're gone. But then again, this is an intro course, I'm sure there are uses for it.