C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 1st, 2008, 10:02 AM
CDCAREY089 CDCAREY089 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 9 CDCAREY089 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 25 m 52 sec
Reputation Power: 0
Syntax errors - Last Part of the program: Owner

Okay. I have a couple of switches in this function and I was wondering how I can fix this part of the program because it brings up a jump to switch case error.


This is the header:

Code:
#ifndef JJAC_O_H
#define JJAC_O_H

class Users
{
  public:
    void users();
    void ownerNames( string, string, string, string );
    void viewExternal();
    void workExternal();
};

#endif





This is the class file:


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

#include "JJAC_O.h"

void Users::ownerNames( string own1, string own2, string own3, string own4 )
{
  own1 = "Jessica";
  own2 = "Jerald";
  own3 = "Adeola";
  own4 = "Ciara";
}

void Users::users()
{
  int code;

  cout << "Welcome to JJAC Gaming.\n"
         << "Please choose one of the following options:\n"
         << "1 - Player\n"
         << "2 - Employee\n"
         << "3 - Owner\n"
         << "4 - Exit\n";
cin >> code;

while( code != 4 )
{
  switch( code )
  {
    case 1:
      cout << "\nYou are not authorized to use this area."
             << "\nYou will be redirected to the exiting system.";
      break;

    case 2:
      int employeeCode;
      cout << "\nWelcome to JJAC Games - Employee Section.\n"
             << "\nFor security purposes, please input the company given code: ";
      cin >> employeeCode;

      switch( employeeCode )
      {
        case 1:
          char yesno;
          cout << "Welcome, Jessica Kennedy.\n"
                 << "Would you like to modify the employee files( y/n )? ";
          cin >> yesno;
          cout << endl;

          if( yesno == 'y' )
            cout << "\nAccessing data now . . . .\n"
                   << "\nUnable to access without password.\n"
                   << "\nRedirecting you to secondary menu . . .\n";
          break;

        case 2:
          char yesno2;
          cout << "Welcome, Jerald Dawson.\n"
                 << "Would you like to modify the employee files( y/n )? ";
          cin >> yesno2;
          cout << endl;

          if( yesno2 == 'y' )
            cout << "\nAccessing data now . . . .\n"
                   << "\nUnable to access without password.\n"
                   << "\nRedirecting you to secondary menu . . .\n";
          break;

        case 3:
          char yesno3;
          cout << "Welcome, Adeola Odunsi.\n"
                 << "Would you like to modify the employee files( y/n )? ";
          cin >> yesno3;
          cout << endl;

          if( yesno3 == 'y' )
            cout << "\nAccessing data now . . . .\n"
                   << "\nUnable to access without password.\n"
                   << "\nRedirecting you to secondary menu . . .\n";
          break;

        case 4:
          char yesno4;
          cout << "Welcome, Ciara Carey.\n"
                 << "Would you like to modify the employee files( y/n )? ";
          cin >> yesno4;
          cout << endl;

          if( yesno4 == 'y' )
            cout << "\nAccessing data now . . . .\n"
                   << "\nUnable to access without password.\n"
                   << "\nRedirecting you to secondary menu . . .\n";
          break;

        case 5:
          char yesno5;
          cout << "\nWelcome, current employee.\n"
                 << "Would you like to view information( y/n )?\n";
          cin >> yesno5;

          if( yesno5 == 'y' )
            viewExternal();
          break;

        case 6:
          cout << "\nWelcome, former employee."
                 << "\nYou need permission to access this information."
                 << "\nPlease see an owner in order to access the information."
                 << "\nThank you."
                 << "\nRedirecting you to secondary menu . . .\n";
          break;

       case 7:
         cout << "\nWelcome, new employee.\n"
                << "At this time, you need to view this information only\n"
                << "while a current employee or an owner is present.\n"
                << "\nThank you for your interests.\n";
         break;

       default:
         cout << "\nAn incorrect employee code was entered."
                << "\nEnter a correct code at prompt.\n";
         break;
    }

    case 3:
      string owner;

      string own1;
      string own2;
      string own3;
      string own4;

      ownerNames( own1, own2, own3, own4 );

      cout << "\nPlease enter password: ";
      cin >> owner;

      if( owner != own1 || owner != own2 || owner != own3 || owner != own4 )
      {
        int misspass = 1;

        while( misspass != 3 )
        {
          cout << "\nIncorrect password."
                 << "\nAttempt " << misspass << " of 3"
                 << "\nEnter a correct password: ";
          cin >> misspass;

          misspass++;
        }
      }

      if( owner == own1 || owner == own2 || owner == own3 || owner == own4 )
        cout << "Welcome, " << owner << ".\n"
               << "\nPlease enter data into the file: ";
      workExternal();
      break;

    default:
      cout << "Incorrect code. Try again:";
      break;
  }
}

void Users::workExternal()
{
  ofstream outJJACFile( "JJAC.dat" );

  if( !outJJACFile )
  {
    cerr << "File could not be opened.";
    exit( 1 );
  }

  double pay;
  string position;
  string name;

  cout << "Please enter the employee's name, position, and pay: ";
  cin >> name >> position >> pay;

  while( cin >> name >> position >> pay )
  {
    outJJACFile << name << ' ' << position << ' ' << pay;
    cout << "?";
  }
}

void Users::viewExternal()
{
  ifstream inJJACFile( "JJAC.dat", ios::in )

  if( !inJJACFile )
  {
    cerr << "File could not be opened.";
    exit( 1 );
  }

  cout << "\nPulling up data: \n"

  cout << "Name of Employee" << setw( 5 ) << "Position" << setw( 5 ) << "Pay"
       << endl << fixed << showpoint;

  do
  {
    cout << left << setw( 10 ) << name << setw( 13 ) << position
         << setw( 7 ) << setprecision( 2 ) << right << pay << endl;
  } while( inJJACFile >> name >> position >> pay )
}




These are the errors:


Code:
JJAC_O.cpp: In member function `void Users::users()':
JJAC_O.cpp:164: jump to case label
JJAC_O.cpp:136:   crosses initialization of `std::string own4'
JJAC_O.cpp:135:   crosses initialization of `std::string own3'
JJAC_O.cpp:134:   crosses initialization of `std::string own2'
JJAC_O.cpp:133:   crosses initialization of `std::string own1'
JJAC_O.cpp:131:   crosses initialization of `std::string owner'
JJAC_O.cpp:171: declaration of `void Users::workExternal()' outside of class is 
   not definition
JJAC_O.cpp:171: syntax error before `{' token
JJAC_O.cpp:174: `outJJACFile' undeclared (first use this function)
JJAC_O.cpp:174: (Each undeclared identifier is reported only once for each 
   function it appears in.)

Internal compiler error: Error reporting routines re-entered.
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.




Please help if possible. Thank you.

Reply With Quote
  #2  
Old December 1st, 2008, 03:45 PM
Bobidybob's Avatar
Bobidybob Bobidybob is offline
Contributing Abuser
Click here for more information
 
Join Date: Apr 2007
Location: Starkville, MS
Posts: 301 Bobidybob User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 Days 5 h 29 m 15 sec
Reputation Power: 2
Send a message via AIM to Bobidybob
dont forget to put a break after the nested switch in case 2

Code:
case 2:
      int employeeCode;
      cout << "\nWelcome to JJAC Games - Employee Section.\n"
             << "\nFor security purposes, please input the company given code: ";
      cin >> employeeCode;

      switch( employeeCode )
      {
      //blah blah blah
      }
      break;
__________________

Reply With Quote
  #3  
Old December 1st, 2008, 10:04 PM
CDCAREY089 CDCAREY089 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 9 CDCAREY089 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 25 m 52 sec
Reputation Power: 0
Okay. That didn't work so I took out the default case, I know it's a bad idea, and after solving the errors I knew got these syntax errors:


Code:
JJAC_O.cpp: In member function `void Users::users()':
JJAC_O.cpp:169: declaration of `void Users::workExternal()' outside of class is 
   not definition
JJAC_O.cpp:169: syntax error before `{' token
JJAC_O.cpp:172: `outJJACFile' undeclared (first use this function)
JJAC_O.cpp:172: (Each undeclared identifier is reported only once for each 
   function it appears in.)
JJAC_O.cpp: In member function `void Users::viewExternal()':
JJAC_O.cpp:216: syntax error before `}' token
JJAC_O.cpp:211: confused by earlier errors, bailing out


for this program:



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

#include "JJAC_O.h"

void Users::ownerNames( string own1, string own2, string own3, string own4 )
{
  own1 = "Jessica";
  own2 = "Jerald";
  own3 = "Adeola";
  own4 = "Ciara";
}

void Users::users()
{
  int code;

  cout << "Welcome to JJAC Gaming.\n"
         << "Please choose one of the following options:\n"
         << "1 - Player\n"
         << "2 - Employee\n"
         << "3 - Owner\n"
         << "4 - Exit\n";
cin >> code;

 while( code != 4 )
{
  switch( code )
  {
    case 1:
      cout << "\nYou are not authorized to use this area."
             << "\nYou will be redirected to the exiting system.";
      break;

    case 2:
      int employeeCode;
      cout << "\nWelcome to JJAC Games - Employee Section.\n"
             << "\nFor security purposes, please input the company given code: ";
      cin >> employeeCode;

      switch( employeeCode )
      {
        case 1:
          char yesno;
          cout << "Welcome, Jessica Kennedy.\n"
                 << "Would you like to modify the employee files( y/n )? ";
          cin >> yesno;
          cout << endl;

          if( yesno == 'y' )
            cout << "\nAccessing data now . . . .\n"
                   << "\nUnable to access without password.\n"
                   << "\nRedirecting you to secondary menu . . .\n";
          break;

        case 2:
          char yesno2;
          cout << "Welcome, Jerald Dawson.\n"
                 << "Would you like to modify the employee files( y/n )? ";
          cin >> yesno2;
          cout << endl;

          if( yesno2 == 'y' )
            cout << "\nAccessing data now . . . .\n"
                   << "\nUnable to access without password.\n"
                   << "\nRedirecting you to secondary menu . . .\n";
          break;

        case 3:
          char yesno3;
          cout << "Welcome, Adeola Odunsi.\n"
                 << "Would you like to modify the employee files( y/n )? ";
          cin >> yesno3;
          cout << endl;

          if( yesno3 == 'y' )
            cout << "\nAccessing data now . . . .\n"
                   << "\nUnable to access without password.\n"
                   << "\nRedirecting you to secondary menu . . .\n";
          break;

        case 4:
          char yesno4;
          cout << "Welcome, Ciara Carey.\n"
                 << "Would you like to modify the employee files( y/n )? ";
          cin >> yesno4;
          cout << endl;

          if( yesno4 == 'y' )
            cout << "\nAccessing data now . . . .\n"
                   << "\nUnable to access without password.\n"
                   << "\nRedirecting you to secondary menu . . .\n";
          break;

        case 5:
          char yesno5;
          cout << "\nWelcome, current employee.\n"
                 << "Would you like to view information( y/n )?\n";
          cin >> yesno5;

          if( yesno5 == 'y' )
            viewExternal();
          break;

        case 6:
          cout << "\nWelcome, former employee."
                 << "\nYou need permission to access this information."
                 << "\nPlease see an owner in order to access the information."
                 << "\nThank you."
                 << "\nRedirecting you to secondary menu . . .\n";
          break;

       case 7:
         cout << "\nWelcome, new employee.\n"
                << "At this time, you need to view this information only\n"
                << "while a current employee or an owner is present.\n"
                << "\nThank you for your interests.\n";
         break;

       default:
         cout << "\nAn incorrect employee code was entered."
                << "\nEnter a correct code at prompt.\n";
         break;
    }
    break;

    case 3:
      string owner;

      string own1;
      string own2;
      string own3;
      string own4;

      ownerNames( own1, own2, own3, own4 );

      cout << "\nPlease enter password: ";
      cin >> owner;

      if( owner != own1 || owner != own2 || owner != own3 || owner != own4 )
      {
        int misspass = 1;

        while( misspass != 3 )
        {
          cout << "\nIncorrect password."
                 << "\nAttempt " << misspass << " of 3"
                 << "\nEnter a correct password: ";
          cin >> misspass;

          misspass++;
        }
      }

      if( owner == own1 || owner == own2 || owner == own3 || owner == own4 )
        cout << "Welcome, " << owner << ".\n"
               << "\nPlease enter data into the file: ";
      workExternal();
      break;

  }
}

void Users::workExternal()
{
  ofstream outJJACFile( "JJAC.dat" );

  if( !outJJACFile )
  {
    cerr << "File could not be opened.";
    exit( 1 );
  }

  double pay;
  string position;
  string name;

  cout << "Please enter the employee's name, position, and pay: ";
  cin >> name >> position >> pay;

  while( cin >> name >> position >> pay )
  {
    outJJACFile << name << ' ' << position << ' ' << pay;
    cout << "?";
  }
}

void Users::viewExternal()
{
  ifstream inJJACFile( "JJAC.dat", ios::in );

  if( !inJJACFile )
  {
    cerr << "File could not be opened.";
    exit( 1 );
  }

  string name;
  string position;
  double pay;

  cout << "\nPulling up data: \n";

  cout << "Name of Employee" << setw( 5 ) << "Position" << setw( 5 ) << "Pay"
       << endl << fixed << showpoint;

  do
  {
    cout << left << setw( 10 ) << name << setw( 13 ) << position
         << setw( 7 ) << setprecision( 2 ) << right << pay << endl;
  } while( inJJACFile >> name >> position >> pay )
}

Last edited by CDCAREY089 : December 2nd, 2008 at 09:20 AM. Reason: Replacing old text with new program text

Reply With Quote
  #4  
Old December 4th, 2008, 07:36 AM
Bobidybob's Avatar
Bobidybob Bobidybob is offline
Contributing Abuser
Click here for more information
 
Join Date: Apr 2007
Location: Starkville, MS
Posts: 301 Bobidybob User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 Days 5 h 29 m 15 sec
Reputation Power: 2
Send a message via AIM to Bobidybob
You're missing a closing bracket somewhere in your users() function.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Syntax errors - Last Part of the program: Owner


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT