Another Coin Counting Program

This is a discussion on Another Coin Counting Program within the C++ Programming forums, part of the General Programming Boards category; I've been away from programming for a long time, and starting at this spot, but I get a wierd error ...

  1. #1
    the Wizard
    Join Date
    Aug 2004
    Posts
    109

    Post Another Coin Counting Program

    I've been away from programming for a long time, and starting at this spot, but I get a wierd error that I can't remember how to fix..:

    Code:
    ///////////////////////////
    // Coin program 
    // ------------
    //
    // Calculates which coins
    // to give to a person
    // if he pays a product
    // with a certain amount
    // of money..
    ///////////////////////////
    //includes
    #include <iostream.h>
     
    //Start
    int main() {
    int money; //pengene
    int en = 0, to = 0, fem = 0, ti = 0, tyve = 0, halvtreds = 0; //under 100
    int hundrede = 0, tohundrede = 0, femhundrede = 0; //under 1000
    int tusind = 0, totusind = 0, femtusind = 0; //resten
    int y=0;
    do {
     
    cout << "What is the change amount?";
    cin >> money;
    if(money >= 5000) {
    money -= 5000;
    femtusind++;
    continue;
    }
    if(money >= 2000) {
    money -= 2000;
    totusind++;
    continue;
    }
    if(money >= 1000) {
    money -= 1000;
    tusind++;
    continue;
    }
    if(money >= 500) {
    money -= 500;
    femhundrede++;
    continue;
    }
    if(money >= 200) {
    money -= 200;
    tohundrede++;
    continue;
    }
    if(money >= 100) {
    money -= 100;
    hundrede++;
    continue;
    }
    if(money >= 50) {
    money -= 50;
    halvtreds++;
    continue;
    }
    if(money >= 20) {
    money -= 20;
    tyve++;
    continue;
    }
    if(money >= 10) {
    money -= 10;
    ti++;
    continue;
    }
    if(money >= 5) {
    money -= 5;
    fem++;
    continue;
    }
    if(money >= 2) {
    money -= 2;
    to++;
    continue;
    }
    if(money >= 1) {
    money -= 1;
    en++;
    continue;
    }
    cout << "You give this to the customer:" << endl;
    cout << "5000:" << femtusind << endl;
    cout << "2000:" << totusind << endl;
    cout << "1000:" << tusind << endl;
    cout << "500:" << femhundrede << endl;
    cout << "200:" << tohundrede << endl;
    cout << "100:" << hundrede << endl;
    cout << "50:" << halvtreds << endl;
    cout << "20:" << tyve << endl;
    cout << "10:" << ti << endl;
    cout << "5:" << fem << endl;
    cout << "2:" << to << endl;
    cout << "1:" << en << endl;
    cout << "Want to quit? (yes = 1, no = 2)" << endl;
    cin >> y;
    } while(y != 1);
    return 0;
    }
    My error is:
    LIBCD.lib(_flsbuf.obj) : fatal error LNK1190: invalid fixup found, type 0x000E

    It's under linking.

    Btw. I know the program is a bit long, but it's made over danish kroners.

    I would appreciate any help.
    Thx in advance.
    Last edited by MipZhaP; 01-21-2005 at 01:05 AM.
    -//Marc Poulsen -//MipZhaP

    He sat down, he programmed, he got an error...

  2. #2
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    What compiler are you using? Everything that I've read from Google suggests that you need to try a clean rebuild.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  3. #3
    the Wizard
    Join Date
    Aug 2004
    Posts
    109
    I'm using Microsoft Visual Studio 98
    -//Marc Poulsen -//MipZhaP

    He sat down, he programmed, he got an error...

  4. #4
    Registered User
    Join Date
    Oct 2004
    Posts
    63
    First two things I noticed:

    #include<iostream.h> is outdated, simply remove the .h

    Second, you will have to put using namespace std; near the top as well (under include works fine) if you want to use cout without puting std before each one (same for cin)

    Also, you may want to space your programs better and comment them. Makes them easier to read - making it easier to find bugs.

    Your code seems a little wierd to me. I don't know whether it is cause I'm a newb or whether its because it actually is wierd
    Last edited by Philandrew; 01-20-2005 at 11:37 PM.
    -Webmaster-
    http://www.koaworld.com
    Pr0gr4m|\/|1Ng n00b

  5. #5
    the Wizard
    Join Date
    Aug 2004
    Posts
    109
    Thx for the answer Philandrew, it's the tag that makes my code a little wierd

    I'll change that with the using namespace std. Damn. Wierd that I could forget it.
    -//Marc Poulsen -//MipZhaP

    He sat down, he programmed, he got an error...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 08-11-2008, 12:50 AM
  2. Counting program
    By 182 in forum C++ Programming
    Replies: 6
    Last Post: 02-18-2006, 07:33 PM
  3. Replies: 5
    Last Post: 01-31-2006, 12:54 AM
  4. program error :counting length of string
    By bigjoke in forum C Programming
    Replies: 19
    Last Post: 12-27-2005, 02:21 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

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