Results 1 to 6 of 6

Thread: Advice

  1. #1

    Thread Starter
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Post Advice

    Hello, please help.
    I have a guy called: "TZ" and a guy called: "WY".
    TZ has 1000 salary
    WY has 10 salary

    Input the NAME on startup, and then the program will identify either it's TZ or WY or others... using the command "switch"

    CONSOLE RELATED
    Thanks a lot

    prog_tom
    JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
    http://physics.sviesoft.com/forum

  2. #2
    Addicted Member
    Join Date
    Aug 2001
    Location
    I'm mobile
    Posts
    166
    isn't it just to use the switch as usual?

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    	char name[2];
    	cout << "Please enter your name: ";
    	cin >> name;
    
    	switch(name[0])
    	{
    	case 'T': cout << "hi ty";
    		break;
                    case 'W': cout << "hi WY";
    		break;
    	default: cout << "hi you";
    		break;
    	}
    
    	return 0;
    }
    [p r a e t o r i a n]

  3. #3

    Thread Starter
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    How come?

    I declared:
    Code:
    char you[100];
    how come I can't set the Value of it during
    main(){}?

    Code:
    you="ME AND YOU!";

    prog_tom
    JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
    http://physics.sviesoft.com/forum

  4. #4

    Thread Starter
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Post ANOTHER ONE

    PHP Code:
    #include <iostream>
    using namespace std;
    int main(){
        
    char POS[100];
        
    int SAL;
        
    cout<<"Please enter your Position in Sviesoft:"<<endl;
        
    cin>>POS;
        switch(
    POS[0]){
        case 
    'pddddddd':cout<<"WOW!!! PROGRAMMER, YOUR SALERY IS:"<<endl;SAL=5000;cout<<SAL<<endl;break;
        case 
    'MANAGER':cout<<"SURE, MANAGE TOM IF YOU CAN!"<<endl;SAL=3998;cout<<SAL<<endl;break;
        case 
    'TOMZHANG':cout<<"BOSS!!! YOU DECIDE!"<<endl;cin>>SAL;cout<<"You get! "<<SAL<<" Dollars!!"<<endl;break;
        default:
    cout<<"I'm sorry. There's no record of your position in Sviesoft"<<endl;break;}
        return 
    0;} 
    Anyone knows how to solve this?

    prog_tom
    JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
    http://physics.sviesoft.com/forum

  5. #5
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    #1 - putting all that code on single lines makes it very difficult to read.

    #2 - You can't switch on anything except int's and char's. But only one char. switching on 'TOMZHANG' is not legal.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    you'll need a series of if(!strcmp()) statements
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width