Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Programming (http://www.go4expert.com/forums/programming-forum/)
-   -   Writing an Algorithm (http://www.go4expert.com/forums/writing-an-algorithm-t17157/)

rosalie1946 27Apr2009 07:08

Writing an Algorithm
 
I am helping my handicapped son who is taking a computer programming course at ITT-Technical and this one is really Greek to me.
It is
Rewrite the following If-Then-Else If statement as a Select Case Statement.
If selection == 1 Then
Display "You selected A."
Else If selection == 2 Then
Display "You selected 2."
Else If selection == 3 Then
Display "You selected 3."
Else If selection == 4 Then
Display "You selected 4."
Else
Display "Not good with numbers, eh?"
End If

I don't even know where to start? Can you help us. There are several others we'll need help with too!

also do you help with programming exercises???

Rosalie

rosalie1946 27Apr2009 07:09

Re: Writing an Algorithm
 
Can anyone help us with this?

cpulocksmith 27Apr2009 08:35

Re: Writing an Algorithm
 
here i hope this helps
Code:

#include <iostream> //basic input output, allows you to get input and give output
#include <stdio.h>// in this code allows you to pause

using namespace std; // standed library

int main(){//main code block everything importand is in here
   
    int Number = 1;// the number you will input right now it equals 1
    cin>>Number;// asks you for the number
   
    switch (Number)//tells the switch what case it wants
{
case 1://outputs every thing in the case 1 is Number = 1
cout << "you selected 1" <<endl;
break;
case 2://outputs every thing in the case 1 is Number = 2
cout << "you selected 2" <<endl;
break;
case 3://outputs every thing in the case 1 is Number = 3
cout << "you selected 3" <<endl;
break;
case 4://outputs every thing in the case 1 is Number = 4
cout << "you selected 4" <<endl;
break;
}
if (Number > 4){//if the Number is greater then 4 it out puts this
    cout<<"not good with number, hu?"<<endl;
    }
system("pause");//pauses the output so you can see it(this is not really needed)

}


shabbir 27Apr2009 09:07

Re: Writing an Algorithm
 
Moved to programming forum


All times are GMT +5.5. The time now is 05:48.