Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

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.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-14-2008, 03:12 AM
zizimetalique zizimetalique is offline
Newbie
 
Join Date: Nov 2007
Posts: 20
Rep Power: 4
zizimetalique is on a distinguished road
Default Help with my code

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-14-2008, 12:38 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 3,421
Last Blog:
wxWidgets is NOT code ...
Rep Power: 37
WingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to behold
Default Re: Help with my code

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-14-2008, 01:35 PM
zizimetalique zizimetalique is offline
Newbie
 
Join Date: Nov 2007
Posts: 20
Rep Power: 4
zizimetalique is on a distinguished road
Default Re: Help with my code

Quote:
Originally Posted by WingedPanther View Post
What error messages/output are you getting?
What output do you think you should be getting for the input provided?
as far as the output i want i expect the pro to display " the account nmber, account type, current balance, if there is any service charge i want the prog to show me display that too.
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-14-2008, 11:13 PM
dargueta dargueta is offline
Guru
 
Join Date: Oct 2007
Age: 18
Posts: 793
Last Blog:
Programs Under the Hoo...
Rep Power: 13
dargueta is a jewel in the roughdargueta is a jewel in the roughdargueta is a jewel in the roughdargueta is a jewel in the rough
Default Re: Help with my code

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-15-2008, 09:10 AM
Oigen Oigen is offline
Learning Programmer
 
Join Date: Jul 2008
Posts: 40
Rep Power: 2
Oigen is on a distinguished road
Default Re: Help with my code

Too many problems with the code, I can't count them all. I'll get back later with something.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 07-16-2008, 06:30 PM
zizimetalique zizimetalique is offline
Newbie
 
Join Date: Nov 2007
Posts: 20
Rep Power: 4
zizimetalique is on a distinguished road
Default New Code, Help with synthax!

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:23: error: âminimumbalanceâ was not declared in this scope
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-16-2008, 10:18 PM
dargueta dargueta is offline
Guru
 
Join Date: Oct 2007
Age: 18
Posts: 793
Last Blog:
Programs Under the Hoo...
Rep Power: 13
dargueta is a jewel in the roughdargueta is a jewel in the roughdargueta is a jewel in the roughdargueta is a jewel in the rough
Default Re: Help with my code

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 07-16-2008, 10:45 PM
zizimetalique zizimetalique is offline
Newbie
 
Join Date: Nov 2007
Posts: 20
Rep Power: 4
zizimetalique is on a distinguished road
Default Re: Help with my code

Quote:
Originally Posted by dargueta View Post
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.
thanks, whats the CODE tags? sorry m not sure what it is.

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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 07-16-2008, 10:55 PM
dargueta dargueta is offline
Guru
 
Join Date: Oct 2007
Age: 18
Posts: 793
Last Blog:
Programs Under the Hoo...
Rep Power: 13
dargueta is a jewel in the roughdargueta is a jewel in the roughdargueta is a jewel in the roughdargueta is a jewel in the rough
Default Re: Help with my code

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 ;
Bulky, I know, but that's the way it has to be done. You also need to declare totalamount, minimbalance, and currentbalance as float instead of int. Money is in decimals, not just integers.

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 07-21-2008, 12:17 PM
Shadowtech's Avatar   
Shadowtech Shadowtech is offline
Newbie
 
Join Date: Jul 2008
Location: Houston, Tx
Posts: 2
Rep Power: 0
Shadowtech is on a distinguished road
Send a message via AIM to Shadowtech
Default Re: Help with my code

hmmm i found one prob in line 39 your missing a u in account......its not much but i'm also new too c++ but i'll do my best to help XD
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

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


All times are GMT -5. The time now is 11:09 AM.

Contest Stats

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

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 101%


Complete - Celebrate!

Ads