CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Posts
    7

    Homework help please

    Hello, I am having trouble with my homework. I have little experience in C++.

    I have to make a C++ program that will determine whether a store customer has exceeded the credit limit on a charge account.

    I've included a pic of what the output is supposed to be

    This is what I have so far:

    #include <iostream>
    using namespace std;

    int main()
    {
    int account = 0;
    float balance = 0;
    float charges = 0;
    float credits = 0;
    float limit = 0;

    cout << "Enter account number 100, 200, or 300 (or -1 to quit): " << endl;
    cin >> account;
    if (account = 100)
    {
    cout << "Enter beginning balance: " << endl;
    cin >> balance >> endl;
    cout << "Enter total charges: " << endl;
    }



    return 0;
    }

    If anyone could give me some guidance please??
    Attached Images Attached Images  

  2. #2
    Join Date
    Sep 2009
    Posts
    57

    Re: Homework help please

    Your problem is in this line
    Code:
    if(account = 100)
    If you use the '=' operator, the account will be set to 100. You should use the '==' operator to check values. This can be done like this:
    Code:
    if(account == 100)

  3. #3
    Join Date
    Jun 2009
    Location
    France
    Posts
    2,513

    Re: Homework help please

    Code:
    cin >> balance >> endl;
    This should be:

    Code:
    cin >> balance
    How do you expect to read your input into a linebreak?

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

Featured