Programming C++

The ATM Transaction Validator requires a loop and if-then logic. You will write the output to a file called statement.txt and read in a file called customer.txt which contains the following information on each line of the file:

Customer last name (two words followed by a comma as a delimiter)
Checking account balance
Transaction type code
Transaction amount

Provide an appropriate error message if the file cannot be found.
Remember to echo each input item as well
A negative amount should cause an error message to be written and the transaction ignored
Invalid transaction types must be reported as errors
All monetary values should be printed with 2 decimal places.

Transaction type codes are (W)ithdraw, (D)eposit, (R)eport the balance

At the end of the transaction the program writes out the new balance or why it couldn't be done.

In any case, if the ending balance is below $300, a warning message should be printed

You need to create the input data file (customer.txt) and use the following data to test your program:
Joe Turing, 4124.50 D 200
Charles Babbage, 300.00 D 100
Sam Backus, 350.25 W 51
Sam Hopper, 600.50 X 600
Robert McCarthy, 1000.00 R 0
Jack Atanasoff, 200.00 W 200
Anne Stroustrup, 300.75 W 301
Amanda Hollerith, 500.00 W -2
Readme First sticky wrote:
Don't post homework questions
Those questions are for you to work out, so that you will learn from the experience. It is OK to ask for hints, but not for entire solutions.

You did not show your attempt, nor did you present any specific question.
Ok...Thanks... I have attempted the question..Can't produce the output



This is the code I have so far

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;

void main()
{
double amtDeposited = 0.0;
double amtReported = 0.0;
double amtWithdrawn = 0.0;

string custName = "", type = "";
double Checkingaccountbalance;
char Transactiontypecode;
double Transactionamount;

ifstream fin("customer.txt");
ofstream fout("statement.txt");
fout << showpoint << fixed << setprecision(2);

while(!fin.eof())
{
fin >> custName;
fin >> Checkingaccountbalance;
fin >> Transactiontypecode;
fin >> Transactionamount;

fout << "Name: " << custName << endl;
fout << "Accountbalance: " << Checkingaccountbalance << endl;
fout << "Transaction: " << Transactiontypecode << endl;
fout << "Amount: " << Transactionamount << endl;

switch (Transactiontypecode)
{
case 'W':
type = "Withdraw";
You need a getline with a delimiter.
http://www.cplusplus.com/reference/string/string/getline/
Can you show me an example? of a getline How does the code look so far?
getline(cin, name, ',');
Would I put that in the while loop?
of course
Topic archived. No new replies allowed.