Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

c++ help please?

Name: Anonymous 2007-12-06 10:34

Hey, i am having some trouble with this c++ code i am working on.  the switch is not working right and it just loops with out accepting input. any help is appriciated.

#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

void Menu(void);
void TAMSaleY(void);
void TAMSaleQ(void);
void MEASales(void);
void GLSales(void);
void AnyKey(void);

char *Month[12]={"January","Febuary","March","April","May","June","July","August","September","October","November","December"};
int Msale[12] = {46987,43768,38987,36181,35129,40245,52156,49546,51120,47345,45675,53769},X;

void main()
{    do
    {    Menu();
        switch(X)
        {    case'1':
                TAMSaleY();
                break;
            case'2':
                TAMSaleQ();
                break;
            case'3':
                MEASales();
                break;
            case'4':
                GLSales();
                break;
            case'5':
                break;
                X=5;
            default:
                cout << "\nEnter 1,2,3,4 or 5." << endl;
                AnyKey();
        }
    }while(X != '5');

} // end of main()

void AnyKey(void)
{    system("pause");
    system("cls");
}

void Menu(void)
{    system("cls");
    cout << "Enter a selection:\n\n1)Total and Average Monthly Sales(Annual)\n2)Total and Average Monthly Sales(Quaterly)\n3)Months Exceeding Average Monthly Sales\n4)Highest and Lowest Performing Month\n5)Exit\n";
}

Name: Anonymous 2007-12-06 11:17

YOU AREN'T READING ANYWHERE FROM THE KEYBOARD YOU FUCKING IDIOT

Name: Anonymous 2007-12-06 11:29

Wow...thanks, i cant believe i fucked that shit up.lol

Name: Anonymous 2007-12-06 11:48

How did I abuse system()?

Name: Anonymous 2007-12-06 11:50

even with a cin for X the switch still wont work.

#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

void Menu(void);
void TAMSaleY(void);
void TAMSaleQ(void);
void MEASales(void);
void GLSales(void);
void AnyKey(void);

char *Month[12]={"January","Febuary","March","April","May","June","July","August","September","October","November","December"};
int Msale[12] = {46987,43768,38987,36181,35129,40245,52156,49546,51120,47345,45675,53769},X;

void main()
{    do
    {    Menu();
        switch(X)
        {    case'1':
                TAMSaleY();
                break;
            case'2':
                TAMSaleQ();
                break;
            case'3':
                MEASales();
                break;
            case'4':
                GLSales();
                break;
            case'5':
                break;
                X=5;
            default:
                cout << "\nEnter 1,2,3,4 or 5." << endl;
                AnyKey();
        }
    }while(X != '5');

} // end of main()

void AnyKey(void)
{    system("pause");
    system("cls");
}

void Menu(void)
{    system("cls");
    cout << "Enter a selection:\n\n1)Total and Average Monthly Sales(Annual)\n2)Total and Average Monthly Sales(Quaterly)\n3)Months Exceeding Average Monthly Sales\n4)Highest and Lowest Performing Month\n5)Exit" << endl;
    cin >> X;
    return;
}

Name: Anonymous 2007-12-06 14:08

Use Haskell.

Name: Anonymous 2007-12-08 11:25

>>6
Correct.  They used Haskell on Mythbusters.

Name: Anonymous 2007-12-11 4:20

>>5

Use if/else.

Name: Anonymous !ZMTjkDFhqY 2007-12-21 12:18

First of all, why the fuck do you have ".h" in your include statements? This is deprecated.
Second of all, why the fuck are you using void main?
http://www.gidnetwork.com/b-66.html

Name: Cats777 !ZMTjkDFhqY 2007-12-21 12:19

>>9
This post was me, BTW.

Name: Anonymous 2007-12-25 2:23

Maybe I'm not seeing it, but is X declared anywhere?  If so, it can't be in Menu() otherwise main() won't be able to see it because of the scope.

Don't change these.
Name: Email:
Entire Thread Thread List