Results 1 to 3 of 3

Thread: C++ question

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    yes yes i know it's a vb site but know there are some
    of you out there that know C++ too, so here i go.....

    I guess this is like using select case in VB.

    switch (selection)
    {

    case 1: cout << " How many hours would you like to convert?: ";
    cin >> Hours;
    x1 = (Hours * 60);
    cout << setw(2) << Hours << " Hours equals " << x1 << " Minutes " << endl << endl;
    break;

    case 2: cout << " How many minutes would you like to convert?: " ;
    cin >> Minutes ;
    x2 = (Minutes / 60) ;
    cout << setw(2) << Minutes << " Minutes equals " << x2 << "
    Hours " << endl ;
    break;

    }

    cout << " Would you like to make another selection? yes or no: ";
    cin >> choice;

    If (choice == "yes")
    ??????? How would you be able to start over from the begining of the program or to any point in the program that
    you want to start from?







  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    292
    You could use a goto but those are kinda frowned upon. If you are just repeating one line of code again and again why not use a loop?
    "People who think they know everything are a great annoyance to those of us who do."

  3. #3
    Member
    Join Date
    Mar 2000
    Posts
    62
    i used to use c++ and when i came to a situation like that i always did a do while loop. lets see if i can remember. do something like this.

    str choice = "Yes"

    Do While(choice == "Yes")

    'select code goes here

    cout << "Again";
    cin >> choice

    Loop


    i know my syntax is bunk, but that should get you going

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