Thread: Newbie having problems with errors

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    5

    Newbie having problems with errors

    I am in a Programming design class, not even C++, and am basically trying to make a program from a design I did. I have very limited experience with C++ and feel through reading online that I get the gist of this, I am just having a few errors I can't figure out.


    Here is the code
    Code:
    // Basic C++ info
    
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    // Declare Global Variables
    float fltIncome, fltTaxowed
    
    // Modules
    void TaxTable();
    void LowBracket();
    void MiddleBracket();
    void HighBracket();
    
    // Made the Modules seperate so that if the tax rate changes, you just have to change the module and not entire program
    
    int Main()
    {
    	cout << "Welcome to the WilliamK99 Tax Calculator" << endl;
    	cout << "Please enter your yearly annual taxable income" << endl;
    	cin >> fltIncome;
    	TaxTable();
    
    	return 0;
    }
    
    
    void TaxTable()
    {
    	if ((fltIncome > 0) && (fltIncome <= 50000)){
    	LowBracket ();}
    	else{
    		if ((fltIncome > 50000) && (fltIncome <= 100000)){
    		MiddleBracket();}
    		else{
    			if (fltIncome > 100000) {
    			HighBracket();}
    			else{
    				{cout >> "You have entered an invalid number";
    				}
    			    }
    		     }
    	   }
    	
    return;
    }
    void LowBracket()
    {
    	fltTaxowed = fltIncome * .05;
    	cout << "You owe " << fltTaxowed << " dollars!";
    	return;
    }
    
    void MiddleBracket()
    {
    	fltTaxowed = ((fltIncome - 50000) * .07) + 2500;
    	cout << "You owe " << fltTaxowed << " dollars!";
    	return;
    }
    
    void HighBracket()
    {
    	fltTaxowed = ((fltIncome - 100000) * .09) + 6000;
    	cout << "You owe " << fltTaxowed << " dollars!";
    	return;
    }
    The errors are attached. Thanks for any guidance you can give me. Again I am not looking for the answers, I am looking for a gentle nudge into the right direction.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    1. You are missing a semicolon here:
    Code:
    float fltIncome, fltTaxowed
    2. Your >> should be << (you want to send the info to cout, not get something FROM cout):
    Code:
    cout >> "You have entered an invalid number";
    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Try using an updated compiler instead, such as Visual Studio. Borland is old, outdated.
    And I mentioned to someone else,

    Code:
    	if ((fltIncome > 0) && (fltIncome <= 50000)){
    	LowBracket ();}
    	else{
    		if ((fltIncome > 50000) && (fltIncome <= 100000)){
    		MiddleBracket();}
    		else{
    			if (fltIncome > 100000) {
    			HighBracket();}
    This will only serve to confuse.

    Code:
    	if ((fltIncome > 0) && (fltIncome <= 50000)){
    		LowBracket ();
    	}
    	else{
    		if ((fltIncome > 50000) && (fltIncome <= 100000)){
    			MiddleBracket();
    		}
    		else{
    			if (fltIncome > 100000) {
    				HighBracket();
    			}
    This is far better. Wouldn't you agree? Much easier to read and see the ending bracket.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    5
    Thanks so much, I feel so lame right now, I read and re-read my code and overlooked both minor errors.

    I appreciate the help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Newbie problems with functions (I think)
    By lbraglia in forum C Programming
    Replies: 4
    Last Post: 10-12-2007, 12:37 PM
  2. Linker errors in VC++ 2005
    By C+/- in forum C++ Programming
    Replies: 0
    Last Post: 05-18-2007, 07:42 AM
  3. Im a newbie having problems with dynamic arrays, can anyone help?
    By Dr.Spankenstein in forum C Programming
    Replies: 4
    Last Post: 04-16-2007, 04:54 AM
  4. No errors but problems??
    By raytro2 in forum C Programming
    Replies: 9
    Last Post: 02-14-2003, 09:05 AM
  5. Newbie problems after first linux install ever...
    By Leeman_s in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 01-24-2003, 03:04 PM