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
  #11 (permalink)  
Old 07-22-2008, 03:42 PM
outsid3r's Avatar   
outsid3r outsid3r is offline
Programming Professional
 
Join Date: Jul 2008
Location: Portugal
Age: 20
Posts: 332
Rep Power: 5
outsid3r has a spectacular aura aboutoutsid3r has a spectacular aura about
Default Re: Help with my code

The correction is here:

Code:
#include<iostream>

using namespace std;

int main(){
    int accounttype;
    int totalamount;
    int minimbalance;
    int currentbalance;
    int accountnumber;

	cout << "Choose from the followings, 1 for savings 2 for checkings: ";
    cin >> accounttype;
	cout << "Enter your minimum balance: ";
    cin >> minimbalance;
	cout << "Enter your current balance: ";
    cin >> currentbalance;
	cout << "What is your account number? \nPlease enter your account number: " ;
    cin >> accountnumber;

	if (accounttype == 1)
	{
		if (currentbalance < minimbalance)
			totalamount = currentbalance - 10;
		else
		{
			if (currentbalance >= minimbalance)
				totalamount = currentbalance * 1.04;
		}
	}
	else
	{
		if (accounttype == 2)
		{
			if (currentbalance < minimbalance)
				totalamount = currentbalance - 25;
			else
			{
				if (currentbalance >= minimbalance && currentbalance >= 5000)
					totalamount = currentbalance * 1.05 ;
				else
				{
					if (currentbalance < minimbalance && currentbalance <= 5000)
						totalamount = currentbalance * 1.03;
				}
			}
		}
	}
	
	cout << "Your account type is " << accounttype << endl;
	cout << "Your account number is " << accountnumber << endl;
	cout << "Your current balance which is your total balance is: " << totalamount << endl;

        return 0;
}
Your last code improved greatly, however, you still do many sintax errors (less than before) and logical errors. Check carefully this code i provided and see the changes.

Now some tips:
Try to think about what you need to do step by step, your first error was the variable declarations, you never used accounttype, so in the end it will generate an error because the variable was never initialized.

You used 'select' variable, why? it just doesn't do anything, you need to input the account type directly to 'accounttype' variable.

The conditions were incorrect, first you need to check what accounttype was selected, if was 1, do what you want, else (anything exept 1) if accounttype is 2 then do what you need to do. Always think carefully then you're making conditions.

Another error i realised was 'currentbalance < minimbalance && <= 5000', well, your idea was correct but the sintax not, the language needs to know what value is <= 5000, so i corrected that in this way 'currentbalance < minimbalance && currentbalance <= 5000'.

And thats all

Last edited by outsid3r; 07-22-2008 at 03:46 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
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 02:38 PM.

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: 100%

Ads