Basically the please hit any key to enter doesn't show up in Visual C++.Thanks for help
main
//CS 310
/*Create a text file and input in certain data into the text
file*/
//Program one
#include <iostream>
#include <fstream>
#include "Account.h"
using namespace std;
int main()
{
account b;
char name1[256];
cout<<"enter file name to be opened\n";
cin>>name1;
ofstream infile;
infile.open(name1);
if(!infile)
{
cout<<"File could not open\n";
exit(1);
}
else
{
while(b.get_account_number()!=-1)
{
if(b.get_account_number()==-1)
{
cout<<"account number is one\n";
infile.close();
//exit(1);
}
else
{
cout<<"enter while loop\n";
cin>>b;
infile<<b;
}
}
}
return 0;
}
Interface
//class used to create an account
#include <string>
using namespace std;
class account
{
private:
int account_Number;
string name;
string address;
string city;
string state;
int zip_Code;
double account_Balance;
public:
//default account constructor
account(int=0, string="", string="", string="", string="", int=0, double=0);
//sets the private variables above
void set_account_number(size_t account_Number_Value);
void set_title(string first_Last);
void set_address(string location);
void set_city(string county);
void set_state(string loc);
void set_zip_code(int zip);
void set_account_balance(double user_balance);
//gets the members value
int get_account_number();
string get_title();
string get_address();
string get_city();
string get_state();
int get_zip_code();
double get_account_balance();
};
//overloaded operator to allow an object to be read in
istream& operator>>(istream&in,account& c);
//overload operator to an object to be read to the file
ostream& operator<<(ostream& out, account& z);
IMPLEMENTATION
#include "Account.h"
#include <iostream>
#include <iomanip>
using namespace std;
account::account(int accountNumberValue,string nameValue,string addressValue, string cityValue, string stateValue,
int zipCodeValue,double AccountBalanceValue)
{
set_account_number(accountNumberValue);
set_title(nameValue);
set_address(addressValue);
set_city(cityValue);
set_state(stateValue);
set_zip_code(zipCodeValue);
set_account_balance(AccountBalanceValue);
}
void account::set_account_number(size_t account_Number_Value)
{
account_Number=account_Number_Value;
}
void account::set_title(string first_Last)
{
name=first_Last;
}
void account::set_address(string location)
{
address=location;
}
void account::set_city(string county)
{
city=county;
}
void account::set_state(string loc)
{
state=loc;
}
void account::set_zip_code(int zip)
{
zip_Code=zip;
}
void account::set_account_balance(double user_balance)
{
account_Balance=user_balance;
}
int account::get_account_number()
{
return account_Number;
}
string account::get_title()
{
return name;
}
string account::get_address()
{
return address;
}
string account::get_city()
{
return city;
}
string account::get_state()
{
return state;
}
int account::get_zip_code()
{
return zip_Code;
}
double account::get_account_balance()
{
return account_Balance;
}
istream& operator>>(istream&in,account& c)
{
int number,zip_code,balance;
string accountNumber;
char name[256];
char address[256];
char city[256];
char state[256];
bool a =true;
cout<<"enter account number";
in>>accountNumber;
while(a==true)
{
if(accountNumber.length()==10)
{
a=false;
cout<<"enter your name\n";
in.ignore();
in.getline(name,256);
cout<<"enter your address\n";
in.getline(address,256);
cout<<"enter your city\n";
in.getline(city,256);
cout<<"enter your state\n";
in.getline(state,256);
cout<<"enter your zip_code\n";
in>>zip_code;
cout<<"enter account balance\n";
in>>balance;
number=atoi(accountNumber.c_str());
c=account(number,name,address,city,state,zip_code,balance);
}
else
{
a=true;
while(accountNumber.length()!=10&&accountNumber!="-1")
{
cout<<"please reenter an account number which is 10 digits\n";
in>>accountNumber;
}
}
}
return in;
}
ostream& operator<<(ostream& out,account& z)
{
out<<z.get_account_number()<<"\n"
<<z.get_title()<<"\n"
<<z.get_address()<<"\n"
<<z.get_city()<<"\n"
<<z.get_state()<<"\n"
<<z.get_zip_code()<<"\n"
<<z.get_account_balance()<<"\n";
return out;
}