Thread: newb help

  1. #16
    Registered User
    Join Date
    Jul 2007
    Posts
    8
    Code:
    #include <iostream>
    
    
    using namespace std;
    
    int main()
    {
    
        //declare variables 
        double openingbalance =0;
        double deposits       =0; 
        double withdrawls     =0;   
        double closingbalance =0; 
        
        //enter input items 
        cout << "Enter opening balance: ";
        cin >> openingbalance;
        cout << "Enter deposits: ";
        cin >> deposits;
        cout << "Enter amount withdrawn: ";
        cin >> withdrawls;
        
        //calcuate closingbalance 
        closingbalance= openingbalance + deposits - withdrawals;
        
        //display output item 
        cout << "closingbalance: " << closingbalance << end1;
        
        return 0;
    } // end of main function

  2. #17
    Registered User
    Join Date
    Jul 2007
    Posts
    8
    I am very new to C++ as you can tell any help would be nice

  3. #18
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    that looks pretty good. have you tested it?
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

  4. #19
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    Code:
      cout << "closingbalance: " << closingbalance << end1;
    Should be "endl", not "end1".

  5. #20
    Registered User
    Join Date
    Jul 2007
    Posts
    8
    Thanks for your help, but I am still missing the closingbalance when I test it...

    Code:
    #include <iostream>
    
    
    using namespace std;
    
    int main()
    
    {
    
        //declare variables 
        double openingbalance =0;
        double deposits       =0; 
        double withdrawls     =0;   
        double closingbalance =0; 
        
        //enter input items 
        cout << "Enter opening balance: ";
        cin >> openingbalance;
        cout << "Enter deposits: ";
        cin >> deposits;
        cout << "Enter amount withdrawn: ";
        cin >> withdrawls;
        
        //calcuate closingbalance 
        closingbalance = openingbalance + deposits - withdrawls;
        
        //display output item 
        cout << "closingbalance: " << closingbalance << endl;
        
        return 0;
    } // end of main function

  6. #21
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    Are you having the problem with the console window disappearing when the program ends, so you don't see the last items printed?

    http://faq.cprogramming.com/cgi-bin/...&id=1043284385

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newb Question Character Counting
    By Wilder in forum C Programming
    Replies: 13
    Last Post: 06-22-2008, 11:37 PM
  2. Dogpile the newb!
    By lindy in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 05-23-2008, 08:17 AM
  3. Total newb directx invisable geometry question
    By -pete- in forum Game Programming
    Replies: 5
    Last Post: 08-13-2006, 01:45 PM
  4. Newb C++ Programmer
    By Philandrew in forum C++ Programming
    Replies: 8
    Last Post: 10-19-2004, 08:44 PM
  5. if your not newb you can help me
    By Klinerr1 in forum C++ Programming
    Replies: 6
    Last Post: 05-05-2002, 12:09 AM