|
-
Sep 28th, 2001, 04:50 PM
#1
Thread Starter
Fanatic Member
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
-
Sep 30th, 2001, 05:35 AM
#2
Addicted Member
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;
}
-
Sep 30th, 2001, 09:37 PM
#3
Thread Starter
Fanatic Member
How come?
I declared:
how come I can't set the Value of it during
main(){}?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Sep 30th, 2001, 09:57 PM
#4
Thread Starter
Fanatic Member
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
-
Sep 30th, 2001, 10:31 PM
#5
#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
-
Oct 3rd, 2001, 04:03 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|