Help me out?

Okay I'm in quite a pickle.. I believe the program almost done however I quite know what put it the lines I skipped. I'll leave what my issues are how they are suppose to inputted.

Okay for my first problem, in case 1. I need to make a decision to make sure there is enough money in the account. And if there is enough I have to subtract the amount to update the balance. If this causes the account to be NSF (non-sufficient funds) the check should not go through and display the message of NSF.

In case 2. I need to update balance by adding to the balance using the same variable.

Lastly in case 3, I need to update the balance by subtracting the charge from the balance, and if there isn't enough funds, I need to display a message that says the card has been denied and will not allow the charge to go through.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <iomanip>
using namespace std;

int main ()

{
	double balance = 0.0;
	double check = 0.0;
	double deposit = 0.0;
	double charge = 0.0;
	int selection = 0;
	
	cout << "What is your current balance amount? ";
	cin >> balance;
	
	cout << "Please choose what you would like to do.\n" //The user has several opintions to user with the bank's features.
		<< "1. Check\n" //Will allow the user to use a check.
		<< "2. Deposit\n" //User can deposit money into his/her account.
		<< "3. Charge\n"//User can view the charge amount to their account.
		<< "4. Quit\n" //User can quit the program.
		<< "Selection: ";
	cin >> selection;
	system("CLS");

	switch (selection)
	{
	case 1:
	cout << "Are are going to use a check?\n";
	
	break:
	case 2:
	cout << "How much do you want to deposit?\n";

	break:
	case 3: 
	cout << "How much is the charge of your transacting?\n";

	break:
	case 4:
	cout << " Thank you and have a nice day.\,";
	cin >> selection;
	break;
	}

}
	system ("pause");
	return 0;
}
Last edited on
So, what is your question...? Can't you just use if statements for 1 and 3, and basic addition for 2. If your intent on using switch statements:
1
2
3
4
5
switch(check < balance)
case 0:    // false
    // junk
default:    // true
    // junk 

On number 4, why not just return from the main function their?

And lastly, please don't use system commands, they just tax on your operating system like crazy. getchar() ;)
okay well for case 1: if it is a check you want to prompt them asking how much the check is. Then you will make a decision to make sure there is enough money in the account for the check. If there is enough money, you will subtract the amount update the balance. The variable name you use for the balance needs to stay the same as #1 above (which is the amount of the user has). If it causes the account for NSF charge. Do not let the check go through if it is NSF. You will need to update the balance with the NSF charge. Make sure that all the balances use the same variable name as #1 above.
For case 2: If is a deposit you will want to prompt them asking how much the deposit is. Then update the balance by adding to the balance using the same variable name as #1 and #5. (#5 is basically case 1)
Case 3: If it is a bank charge (like a debit card charge) then you will ask the user what is the charge is. Then you will update the balance by subtracting the charge using the same variable name #1, #5, and #6 above for the balance. If the charge exceeds their balance, display a message that tells them their card has been denied and do not allow the charge to go through. No NSF charge will be added when a charge is denied.
Case 4: After you complete the switch you will then skip some lines and print out the balance after the transaction (same variable name as #1, #5, #6 , #7 Above) with message letting the user know what their balance is. (#6 is the case 2, and #7 is case 3)
You still haven't asked a question. What do you need help with?
Topic archived. No new replies allowed.