Bank Account Calculator

#include <iostream>
#include <Windows.h>

int main()
{

short int current_balance;//current balance of your bank account
short int total_cost;
short int total_earned;
short int new_total = (current_balance + total_earned - total_cost);

std::cout << "Welcome to Account Balance Calculator v1.1\n\n";
std::cout << "Loading...";
Sleep(5000);
std::cout << "Please enter current balance: ";
std::cin >> current_balance;
std::cout << "Please enter total bill amount: ";
std::cin >> total_cost;
std::cout << "Please enter total earned: ";
std::cin >> total_earned;
std::cout << "New Balance: " << new_total << "\n";
Sleep(10000);
std::cout << "Thank You for using Account Calculator v1.1\nHave a nice day!";
Sleep(5000);
}

Hello everyone,

I started out with a simple calculator where you input the variables before you run the program and was successful so decided to try and do it with user input. The first error I'm getting is " The variable 'current_balance' is being used without being initialized." and I'm getting this for total_earned and total_cost as well.
My second problem is after I click continue through these windows it allows me to start inputting my variables but it always ends with new_total being -13108.
This is my day coding and I've looked on the net and looked through my book and can't find my problem so any help would be great!
Thanks
Geoff
The problem is that you are calculating your "new_total" before you actually get the data from the user for the other variables.

You'll need to move that to after you collect all the information. Remember that the program is executed sequentially.
Thank You so much for the help. It works perfectly now.

One more question when posting into the forum most people don't copy paste there code into the post like i did they do it in a grey box somehow like a picture. How is this accomplished? Hopefully I'm not just being retarded lol.
Look on the right side when you're creating your post, you'll see 'Format:' and underneith that a series of buttons. Press the button with <> as the icon. Otherwise, you can just manually type [.code][./code] (without the period) around your code.. It's the same thing.
Last edited on
Sweet! Thanks!
@Ikaron When you want to tell people about [code][/code] tags, here's a little trick so you can write them without the period. Do this: [co[i][/i]de][/co[i][/i]de].
Last edited on
Hah, that's clever. Thanks for that. :)
Topic archived. No new replies allowed.