Please! HELP!

I would really appreciate some help with a program for my Csc 150 class.  I have the program typed in, but it won't run right and I would love some help with it.

Thank you for your reply!
Sarah
InalityAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

InalityAuthor Commented:
Adjusted points to 60
0
simonetCommented:
Can you give more details?
0
ozoCommented:
What's not right when you run it?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

mflamCommented:
Please send the program.
I have 10 yrs experiance.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
InalityAuthor Commented:
I really appreciate this!  I need to add a Boolean Variable to this program -- preferably in the function char GetRed.  If you can tell me how to do this, I would so appreciate it!  

Thank you!

#include <iostream.h>

const float FiveW_P = 10000000;
const float FiveW   = 100000;
const float FourW_P = 5000;
const float FourW   = 100;
const float ThreeW_P= 100;
const float ThreeW  = 5;
const float TwoW_P  = 5;
const float OneW_P  = 2;
const float OneP    = 1;
const float zero    = 0;

float GetWhite();
char GetRed();
float Winning(float, char);
void PrintWin(float);

int main()
{
     float white;
     char letter;
     float win;

     cout << "This program was designed to allow the user to figure" <<endl;
     cout << "out what amount of money he/she won from the current " <<endl;
     cout << "lottery ticket.  The number of correct white balls and"<<endl;
     cout << "whether or not the powerball was correct should be"    <<endl;
     cout << "entered following the prompt.  The computer will now"  <<endl;
     cout << "calculate and print out what amount of money that the" <<endl;
     cout << "user won." << endl;

     white = GetWhite();
     letter = GetRed();
     win = Winning(white, letter);
     PrintWin(win);
     return 0;
}

float GetWhite()
{
     float num;
     cout << endl;
     cout << "Please enter the number of white balls that you matched" << endl;
     cout << "with the winning numbers." << endl;
     cin  >> num;
     return num;
}

char GetRed()
{
     char letter;
     cout << endl;
     cout << "Please enter Y or N indicating whether or not you correctly" << en
     cout << "guessed the Powerball number." << endl;
     cin  >> letter;
     return letter;
}

float Winning(float white, char letter)
{
     float win;
     if (white==5 && letter=='Y'){
        win = FiveW_P;
     }
     else if (white==5 && letter =='N'){
        win = FiveW;
     }
     else if (white==4 && letter =='Y'){
        win = FourW_P;
     }
     else if (white==4 && letter =='N'){
        win = FourW;
     }
     else if (white==3 && letter =='Y'){
        win = ThreeW_P;
     }
     else if (white==3 && letter =='N'){
        win = ThreeW;
     }
     else if (white==2 && letter =='Y'){
        win = TwoW_P;
     }
     else if (white==1 && letter =='Y'){
        win = OneW_P;
     }
     else if (white==0 && letter =='Y'){
        win = OneP;
     }
     else if (white==0 && letter =='N'){
        win = zero;
     }
     else{
        cout << "This entry is void. Try again." << endl;
        win = zero;
     }
     return win;
}

void PrintWin(float win)
{
     cout <<"You just won $" <<win<< endl;
     return;
}
0
InalityAuthor Commented:
Sorry -- I forgot that I can only offer 145 points -- not 150.

0
mflamCommented:
I think your problem was simple:
You were putting in a small y and n
instead of capital Y and capital N.

I fixed the program up.

Take a look at it in next comment.
Fixes:
1. User explanation is more readable.
2. Comments in code.
3. Added loop for "try again" to work.
   Including print function outside loop.
4. Fixed the check for N to != Y. (That's: NOT EQUALS Y)
5. Fixed the check for Y to
  if was y change it to Y.
6. Added in user interface as to the numbers alowed (5 or less).
7. Added remark in code what correct input supported.

Thanks for the fun.
(No need for boolean. If you insist, please tell me.)
Moshe
0
mflamCommented:
Here's the code: (Moshe)

// console1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream.h>

const float FiveW_P = 10000000;
const float FiveW   = 100000;
const float FourW_P = 5000;
const float FourW   = 100;
const float ThreeW_P= 100;
const float ThreeW  = 5;
const float TwoW_P  = 5;
const float OneW_P  = 2;
const float OneP    = 1;
const float zero    = 0;

float GetWhite();
char GetRed();
float Winning(float, char);
void PrintWin(float);


int main(int argc, char* argv[])
{
    float white;
    char letter;
    float win;

    cout << "This program was designed to allow the user "            << endl;
    cout << "to figure out what amount of money he/she won "      << endl;
    cout << "from the current lottery ticket.  "                        << endl;
      cout << endl;
      cout << "The number of correct white balls (5 or less) "      << endl;
    cout << "and whether or not the powerball was correct, "   << endl;
    cout << "should be entered following the prompt.  "            << endl;
      cout << endl;
      cout << endl;
      cout << "The computer will now calculate and print out "      << endl;
      cout << "the amount of money that the user won."                  << endl;
      
    // Keep trying till win get's a valid entry
    win = 0;
    while (win ==0)
    {
        white = GetWhite();
        letter = GetRed();
        win = Winning(white, letter);
    }
    PrintWin(win);
      // END OF PROGRAM      
    return 0;
}

float GetWhite()
{
    float num;
    cout << endl;
    cout << "Please enter the number of white balls that you matched" << endl;
    cout << "with the winning numbers." << endl;
    cin  >> num;
    return num;
}

char GetRed()
{
    char letter;
    cout << endl;
    cout << "Please enter Y or N indicating whether or not you correctly" << endl;
    cout << "guessed the Powerball number." << endl;
    cin  >> letter;
    if (letter == 'y')
      letter = 'Y';
     return letter;
}

float Winning(float white, char letter)
{
     float win;
     if (white==5 && letter=='Y'){                  // 5,Y
        win = FiveW_P;
     }
     else if (white==5 && letter !='Y'){    // 5,N
        win = FiveW;
     }
     else if (white==4 && letter =='Y'){    // 4,Y
        win = FourW_P;
     }
     else if (white==4 && letter !='Y'){    // 4,N
        win = FourW;
     }
     else if (white==3 && letter =='Y'){    // 3,Y
        win = ThreeW_P;
     }
     else if (white==3 && letter !='Y'){    // 3,N
        win = ThreeW;
     }
     else if (white==2 && letter =='Y'){    // 2,Y
        win = TwoW_P;
     }
     else if (white==1 && letter =='Y'){    // 1,Y
        win = OneW_P;
     }
     else if (white==0 && letter =='Y'){    // 0,Y
        win = OneP;
     }
     else if (white==0 && letter !='Y'){    // 0,N
        win = zero;
     }
     else{
        cout << "This entry is invalid." << endl;
            cout << "Valid entries are: 5,4,3,2,1,0 with Y" << endl;
            cout << "              And: 5,4,3,    0 with N" << endl;
            cout << "    Try again!" << endl;
        win = zero;
     }
     return win;
}

void PrintWin(float win)
{
     cout <<"You just won $" << win << "!" << endl;
     return;
}
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.