warning C4700 HELP

This is a discussion on warning C4700 HELP within the C++ Programming forums, part of the General Programming Boards category; I am working on the program for class that im taking and its not working this is the algorithm that ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    3

    warning C4700 HELP

    I am working on the program for class that im taking and its not working this is the algorithm that Im using but I dont know if im doing it right
    Note: I am very new to this

    Algorithm Name: UPDATE_CHECKBOOK
    Problem Input(s): start_balance - the beginning checkbook balance. xact_amount - the amount of the transaction. xact_type - the type of the transaction (credit or debit). Problem Output(s): new_balance -- the ending checkbook balance. Relevant Formula(s): Adding a credit = (starting balance) + (transaction amount) Subtracting a debit = (starting balance) - (transaction amount) Algorithm:
    BEGIN
    Ask the user for the starting balance.
    Input the starting balance (start_balance).
    Ask the user for the transaction amount.
    Input the amount of the transaction (xact_amount).
    Ask the user for the type of transaction.
    Input the type of transaction (xact_type).
    If (the value of xact_type is "Credit") Then
    Compute new_balance = (start_balance + xact_amount).
    Else
    Compute new_balance = (start_balance - xact_amount).
    End If
    Output the desired value (new_balance).
    END

    Heres what I have

    float main()
    {
    float start_balance, xact_amount, xact_type, new_balance, credit, debit;
    cout << "Please the starting balance: ";
    cin >> start_balance;
    cout << "Please enter the transaction amount: ";
    cin >> xact_amount;
    cout << "Please enter the type of transaction: ";
    cin >> xact_type;
    if (xact_type = credit) {new_balance = start_balance + xact_amount;}
    else if (xact_type = debit) {new_balance = start_balance - xact_amount;}


    return 0;
    }

    HELP ME! Please
    Last edited by rbduck09; 02-12-2011 at 04:40 PM.

  2. #2
    -bleh-
    Join Date
    Aug 2010
    Location
    somewhere in this universe
    Posts
    452
    No such thing as float mAin(). Who taught you that should be shot. Put your code around a code tag. Xact-type is better be bool, I.e 1 for credit and 0 for debit, or any way you want to define it. Then your if statement just becomes
    Code:
    if( xact-type) 
        Do something
    Else
        Do something else
    Last edited by nimitzhunter; 02-12-2011 at 04:46 PM.
    "All that we see or seem
    Is but a dream within a dream." - Poe

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    3
    so what would put next to main instead of float. and what do you mean by bool. Does you mean boolean and is everything else right

    is this line right in my code float start_balance, xact_amount, xact_type, new_balance, credit, debit;
    Sorry for all these questions but I am very new to this.. still trying to figure everything out

  4. #4
    -bleh-
    Join Date
    Aug 2010
    Location
    somewhere in this universe
    Posts
    452
    one of the two legal versions of main:
    Code:
    int main()
    you don't need "credit", and "debit" becuase the value of xact_type represent them. You can use int to represent the boolean type for now.
    Code:
    int xact_type;
    cout << Enter 1 for credit and 0 for debit: "; << something like this would do. 
    cin >> xact_type;
    "All that we see or seem
    Is but a dream within a dream." - Poe

  5. #5
    Registered User
    Join Date
    Feb 2011
    Posts
    3
    This is what I have so far
    Code:
    int main()
    {
    int start_balance, xact_amount, xact_type, new_balance;
    	cout << "Please the starting balance: ";
    cin >> start_balance;
    cout << "Please enter the transaction amount: ";
    cin >> xact_amount;
    int xact_type;
    cout << "Please enter 1 for credit or 0 for debit: ";
    cin >> xact_type;
    
    }
    but it's still giving me errors
    error C2086: 'int xact_type' : redefinition
    see declaration of 'xact_type'

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    I tagged your code, and highlighted the problem.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,535
    Basically it says "you are trying to define/declare something more than once." And easy fix, and Salem even pointed out where.
    Simply put: once is enough.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined reference to.. probably Makefile problem
    By mravenca in forum C Programming
    Replies: 11
    Last Post: 10-20-2010, 04:29 AM
  2. Replies: 2
    Last Post: 09-16-2009, 06:00 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 12:03 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21