Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,267 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,489 people online right now. Registration is fast and FREE... Join Now!




Credit Card Billing system

 
Reply to this topicStart new topic

Credit Card Billing system, I/O I need to know how

tommy321
5 Nov, 2006 - 09:40 PM
Post #1

New D.I.C Head
*

Joined: 5 Nov, 2006
Posts: 2


My Contributions
What am I missing, I need this to read accounts.dat and output to a file the correct sum.. please help
CODE


// A simple credit card billing system

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cctype>
#include <iomanip>

using namespace std;

int main()
{
    int counter = 0;
    int num;
    double oldbal, newbal;
    const double latefee = 29.00;
    const double intrate = 0.15;
    const int minpay = 10;

    ifstream accounts;
    accounts.open("accounts.dat");
    if(accounts.fail())
    {
        cout << "accounts.dat could not be opened. Program aborted\n";
        return 0;
    }
    while(accounts >> accounts.num >> accounts.oldbal)
    {
        accounts.get();
        accounts.getline(account.number);
        counter++;
    }
    cout << "Welcome to the Credit Card Billing\n"

        ofstream accNew;
        do
        {
        accNew.open("accounts.new");
        if (!accNew);
            cout << "That is not a valid file. Try again.\n";
        }while(!accNew);

        while(!accounts.eof())
        {
            accounts.get(oldbal);
            acctNew << oldbal;
        }

        accounts.close();
        acctNew.clost();
        return 0;
}

User is offlineProfile CardPM
+Quote Post

NyeNye
RE: Credit Card Billing System
5 Nov, 2006 - 09:42 PM
Post #2

D.I.C Head
**

Joined: 24 Sep, 2006
Posts: 248


My Contributions
Please post your exact errors with specific lines...



User is offlineProfile CardPM
+Quote Post

tommy321
RE: Credit Card Billing System
5 Nov, 2006 - 09:49 PM
Post #3

New D.I.C Head
*

Joined: 5 Nov, 2006
Posts: 2


My Contributions
QUOTE(NyeNye @ 5 Nov, 2006 - 10:42 PM) *

Please post your exact errors with specific lines...

well, there are no errors I just dont know how to do it, that is what I got so far. the program just says file cannot be read and closes down.

Tommy
User is offlineProfile CardPM
+Quote Post

horace
RE: Credit Card Billing System
5 Nov, 2006 - 11:53 PM
Post #4

D.I.C Addict
Group Icon

Joined: 25 Oct, 2006
Posts: 573



Thanked: 4 times
Dream Kudos: 50
My Contributions
are you executing the program in the directory where the accounts.dat file is? if you are using Linux or OSX do you have the case correct, i.e. file name accounts.dat is not the same as Accounts.dat

User is offlineProfile CardPM
+Quote Post

gregoryH
RE: Credit Card Billing System
6 Nov, 2006 - 01:16 AM
Post #5

D.I.C Regular
Group Icon

Joined: 4 Oct, 2006
Posts: 417


Dream Kudos: 50
My Contributions
QUOTE(horace @ 6 Nov, 2006 - 12:53 AM) *

are you executing the program in the directory where the accounts.dat file is? if you are using Linux or OSX do you have the case correct, i.e. file name accounts.dat is not the same as Accounts.dat

Tommy, Horace

I am thinking from quick glance that maybe Tommy guessed the file would automatically be found in the same folder as the program. unless the program forces the "start in" information to the same folder as the executable you will have trouble.

I concur with Horace on case sensitivity and pathing issue if you are on *nix or Mac.

cheers
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 07:33PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month