Writing an Algorithm

Discussion in 'Programming' started by rosalie1946, Apr 27, 2009.

  1. rosalie1946

    rosalie1946 New Member

    Joined:
    Apr 27, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. rosalie1946

    rosalie1946 New Member

    Joined:
    Apr 27, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Can anyone help us with this?
     
  3. cpulocksmith

    cpulocksmith New Member

    Joined:
    Jul 23, 2008
    Messages:
    289
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    student
    Location:
    canada
    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 likes this.
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Moved to programming forum
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice