|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
hi
i have to write a program that prompts the following from the user:account number, an account type (s for savings and c for checking), minimum balance, and current balance. then the prog should output: the account number, the full account type (savings or checking), the current balance, and a message as described below. For savings accounts, the output current balance is the input balance plus 4% interest. Also a service charge of $10 is subtracted for balances below minimum balance. A message will say whether a charge or interest is in effect. For checking accounts, the output balance is input balance plus 5% interest of amounts up to $5000 over the minimum balance and 3% for excess amounts. Also $25 is charged for balances below minimum balance. A message is displayed as in the savings case. Here is suggested test data: 46728 S 1000 2700 87324 C 1500 7689 79873 S 1000 800 89832 C 2000 3000 98322 C 1000 750 i am not that very good with c++ but your help and yourtime will be appreciated greatly! Code:
#include <iostream>
using namespace std;
int main()
{
constfloat = .04, .05 , .03;
int currentbalance;
int balance;
int servicecharge;
int Savingsaccountnumber;
int Checkingsaccountnumber;
int Savings;
Int Checkings;
int select = 0;
// select 1 = Savings;
// select 2 = Checkings;
cout " Please choose an account 1 for Savings 2 for Checking: " ;
cin >> select;
if (select == 1)
cout << "enter account number";
cin >> Checkingsaccountnumber;
cout << " enter balance ";
cin >> balance;
interest = .04;
currentbalance = balance + .04;
minbalance == currentbalance;
servicecharge = minbalance - 10;
if (minbalance < currentbalance)
servicecharge = currentbalance - 10;
cout << " the service charge is " << servicecharge << endl;
cout << "account type is "<< select 1 << endl;
<< " your account number is "<< Savingsaccountnumber << endl;
<< " your account balance is " << currentbalance <<endl;
else
cout << " your account type is" << select1 << endl;
cout << " your account number is" << Savingsaccontnumber << endl;
cout << " your account balance is" << currentbalance <<endl;
cout << " no service charge is due for now "; << endl;
if (select == 2)
cout << "enter account number " ;
cin >>Savingsvingsaccountnumber;
cout << " enter balance ";
cin << balance;
interest = .05
minbalance == currentbalance;
if (balance > 5000)
currentbalance = balance + .05;
else
if (balance < 5000)
currentbalance = balance + .03;
if (minbalance < currentbalance)
servicecharge = currentbalance - 10;
cout << " the service charge is " << servicecharge << endl;
} else
cout << " no service is due for now " << endl;
cout <<" your account type is " << select 2 << endl;
cout << "your account number is " << Checkingsaccount << endl;
cout << "your balance is " << balance << endl;
Last edited by WingedPanther; 07-14-2008 at 12:36 PM. Reason: add code tags |
| Sponsored Links |
|
|
|
|||||
|
What error messages/output are you getting?
What output do you think you should be getting for the input provided?
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
|
|||
|
Quote:
the error i am getting i try to fix them but i can seem to manage, t he warnings are ok. here are the error: bank.cpp:24: error: âinterestâ was not declared in this scope bank.cpp:25: warning: converting to âintâ from âdoubleâ bank.cpp:26: error: âminbalanceâ was not declared in this scope bank.cpp:31: error: expected `;' before numeric constant bank.cpp:32: error: expected primary-expression before â<<â token bank.cpp:33: error: expected primary-expression before â<<â token bank.cpp:34: error: expected primary-expression before âelseâ bank.cpp:34: error: expected `;' before âelseâ bank.cpp:36: error: âSavingsaccontnumberâ was not declared in this scope bank.cpp:38: error: expected primary-expression before â<<â token bank.cpp:41: error: âSavingsvingsaccountnumberâ was not declared in this scope bank.cpp:43: error: no match for âoperator<<â in âstd::cin << balanceâ bank.cpp:45: error: expected `;' before âminbalanceâ bank.cpp:47: warning: converting to âintâ from âdoubleâ bank.cpp:50: warning: converting to âintâ from âdoubleâ bank.cpp: At global scope: bank.cpp:54: error: expected unqualified-id before âelseâ bank.cpp:56: error: expected constructor, destructor, or type conversion before â<<â token bank.cpp:57: error: expected constructor, destructor, or type conversion before â<<â token bank.cpp:58: error: expected constructor, destructor, or type conversion before â<<â token |
|
|||
|
I found a lot of problems with your code. I don't have time to go through all of them, but here are the first ones I hit:
1) I don't know what constfloat is supposed to do. It looks like you're trying to assign three values to one variable that doesn't have a type. 2) Incorrect formula, should be currentbalance = balance*1.04 3) Balance will always equal 10 when you subtract the service charge. Since minbalance = balance and servicecharge = minbalance - 10, balance - servicecharge = 10 regardless of the other values. 4) You never declare minbalance before you use it 5) checkings is incorrectly declared - int is all lowercase 6) cout << "account type is "<< select 1 << endl; <-- remove the 1. |
|
|||
|
hi !
i changed the code, fixed few errors, here is the New code and the errors below: Once again your help and your kindness will be appreciated! Code:
#include<iostream>
using namespace std;
int main(){
int accounttype;
int totalamount;
int minimbalance;
int currentbalance;
int select = 0;
int accountnumber;
// select 1 = savings;
// select 2 = checkings;
cout << "choose from the followings: 1 for savings 2 for checkings " ;
cin >> select;
cout << " enter your minimum balance ";
cin >> minimbalance;
cout << " enter your current balance ";
cin >> currentbalance;
cout << " what is your account number? Please enter your account number " ;
cin >> accountnumber;
if (select == 1)
{
if (currentbalance < minimumbalance)
totalamount = currentbalance - 10;
}
else
if (currentbalance >= minimumbalance)
{ totalamount = currentbalance * 1.04 ;
if (select == 2)
{
if (currentbalance < minimbalance)
totalamount = currentbalance - 25;
}
else
if (currentbalance >= minimbalance && >= 5000)
{
totalamount = currentbalance * 1.05 ;
}
else
if (currentbalance < minimbalance && <= 5000)
totalamount = currentbalance * 1.03 ;
}
cout << " your account type is " << accounttype << " your account number is " << accountnumber << endl;
cout << " and your current balance which is your Total balance is " << totalamount << endl;
cout << endl;
}
account.cpp:30: error: âminimumbalanceâ was not declared in this scope account.cpp:32: warning: converting to âintâ from âdoubleâ account.cpp:43: error: expected primary-expression before â>=â token account.cpp:45: warning: converting to âintâ from âdoubleâ account.cpp:48: error: expected primary-expression before â<=â token account.cpp:49: warning: converting to âintâ from âdoubleâ Last edited by WingedPanther; 07-17-2008 at 12:22 PM. Reason: add code tags |
|
|||
|
Please use the CODE tags.
You keep switching between using minimumbalance and minimbalance. Pick one or the other, change everything to that one name, and your code should compile without errors, just the typecast warnings. Tip: Always check your spelling. |
|
|||
|
Quote:
thanks for helping me catching my..synthax or my typing mistakes. yes, from now on i will start checking my spelling. now; see i am still not able to fix line 43 and 48 where i have: if(currentbalance >= minimbalance && >= 5000) and line 48: else if (currentbalance < minimbalance && <= 5000) what is wrong with these two lines if you look at my code? could it be my parathesis and my brackets that are wrong? the arrors are the following: account.cpp: In function âint main()â: account.cpp:32: warning: converting to âintâ from âdoubleâ account.cpp:43: error: expected primary-expression before â>=â token account.cpp:45: warning: converting to âintâ from âdoubleâ account.cpp:48: error: expected primary-expression before â<=â token account.cpp:49: warning: converting to âintâ from âdoubleâ thanks for your time and your help! |
|
|||
|
Your syntax is off in lines 43 and 48. You can't have one variable be part of two expressions because it's ambiguous. What you want to say is if((currentbalance >= minimbalance)&&(minimbalance >= 5000)) for line 43 and if((currentbalance < minimbalance)&&(minimbalance <= 5000)) for line 48.
Code:
if((currentbalance >= minimbalance)&&(minimbalance >= 5000))
totalamount = (float)currentbalance * 1.05 ;
else if((currentbalance < minimbalance)&&(minimbalance <= 5000))
totalamount = (float)currentbalance * 1.03 ;
CODE tags - copy and paste your code, then highlight it and click on the button that looks like a pound sign ( # ). Last edited by dargueta; 07-16-2008 at 10:58 PM. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Hi5 tiny slideshow code crap... | Godiva983 | General Programming | 1 | 06-23-2008 05:46 PM |
| Basic Calculator | AfTriX | VB Tutorials | 3 | 02-29-2008 09:53 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |