1) Read an integer # from the file balance.dat that represents the balance on your checkbook (Assume integer #'s only)
2)let the user enter an amount to write a check.
3)If there is enough balance to write teh check then display the message (OK to write check) if the check is overdraft 350.00, from 1-50 dollars then the bank charges 5 dollars more to cash the check so display message (OK to write check , but 5 dollars will be charged due to NSF)
4) remember to chekc if the file exists before you do anything (usethe .fail() function)

Okay, what part are you having trouble with? Keep in mind that if you say you haven't done anything yet, I'll tell you to get lost. If you have done something, you'll need to prove it. Why? Because this is obviously homework, it's obviously easy if you put in a little effort, and maybe I just don't like you.

well ofcourse i have but right now i'm late for work, i will post my work in a while

Okay, what part are you having trouble with? Keep in mind that if you say you haven't done anything yet, I'll tell you to get lost. If you have done something, you'll need to prove it. Why? Because this is obviously homework, it's obviously easy if you put in a little effort, and maybe I just don't like you.

here's what i have

#include <iostream>
#include <conio.h>
#include <fstream>

using namespace std;

int main()
{
      int checkAmount;
       ifstream inBalance;
      ofstream outBalance;
     
      inBalance.open("balance.dat");
      
      if (inBalance.fail())
    { 
       cout << "file balance.dat not found !!!!" << endl;
        getch ();
         exit(1);
      }

     cout << "Please enter check amount: ";
      cin >> checkAmount;

      if (inBalance <= 350)
     {
        cout << "ok to write check" << endl;
      }
   
      if (inBalance >= 350)
      {
      cout << "OK to write check but 5 dollars will be charged due to NSF " << endl;
}

    if (inBalance > 100)
    {
     cout << "the bank will not pay this check"  <<  endl;
    }

     cout << endl;

      outBalance.open("balance.dat")

    getch();
     return 0;

  }

Very close, but inBalance is a stream, not an integer. After you open the file, do something like this:

int balance;
inBalance>> balance;

Then use balance and checkAmount for your conditional statements.

can anyonehelp me

#include <iostream>
#include <conio.h>
#include <fstream>

using namespace std;

int main()
{
	int Amount;
	int balance;

	ifstream inAmount;
	ofstream outAmount;

	inAmount.open("balance.dat");
	
	inBalance >> balance;

	if (inBalance.fail())
	{
		cout << "file balance.dat not found!!!" << endl;
		getch();
		
	}

	cout << "Please enter check amount: ";
	cin >> Amount;

	if (balance <=350)
	{
		cout << "Ok to write check" << endl;
	}

	if (balance >=350)
	{
		cout << "The bank will not pay this check" << endl;
	}

	cout << endl;

	outBalance.open("balance.dat")

	getch();
	return 0;

}

Whats wrong here? Are you having a problem or do you expect someone to write the program for you?

>can anyonehelp me
I did help you. If you have a new question then ask it. The logic for this program is simple, so either you're very stupid, or very lazy. I prefer to assume the latter, so explain exactly what your problem is and we'll help. But we won't do it for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.