please help me, i have to submit project on 1 feb 2015, REMOVE ERRORS AND POST IT, THANKS

#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <string>

using namespace std;

class User
{
private:
string id;
string firstName;
string lastName;
int pin;
double cash;

public:

User()
{
//leave empty
}

User(string i, string f, string l, int p, double c)
{

id = i;
firstName = f;
lastName = l;
pin = p;
cash = c;

}


void changePin(int p)
{

cout<<"Please select a new 4-digit numerical pin"<<endl<<"# ";
cin>>p;

while(p < 999 || p > 10000)
{
cout<<"Invalid Pin. "<<endl<<"Please select a new 4-digit numerical pin"<<endl<<"# ";
cin>>p;
system("cls");
}

pin = p;
cout<<"You pin has been changed to "<<pin<<endl;

}

int getPin()
{
return pin;
}
double getCash()
{
return cash;
}
string getFirstName()
{
return firstName;
}
string getLastName()
{
return lastName;
}
string getId()
{
return id;
}

double setWithdraw(double w)
{

while(cash < w)
{
cout<<"You tryen to rob me? You don't have that much"<<endl
<<"How Much would you like to withdraw?"<<endl<<"$ ";
cin>>w;
}
return cash -= w;

}

double setDeposit(double d)
{
while(d > 10000)
{
cout<<"I would be all about taking more than $10,000 from you and all, "
<<"but it jacks the program up and robs you."<<endl
<<"How much would you like to deposit?"<<endl<<"$ ";
cin>>d;
}
return cash += d;
}

bool isTrue(string tempId, int tempPin)
{

if(id == tempId && pin == tempPin)
{
return true;
}

else
{
return false;
}
}

ifstream done;
done.open("bank.txt");


void getAll(totalUsers)
{
for(int count = 0; count <= totalUsers; count++)
{
done >> users[count] ;
}
}

done.close();

};



int main()
{
ifstream database;
database.open("bank.txt");

int ui;
int ui2;
int tempPin;
int totalUsers = 0;
int activeUser = 0;
double tempCash;
double withdraw;
double deposit;
string tempId;
string tempFirstName;
string tempLastName;
User users[100];


while (!database.eof())
{
database >> tempId >> tempFirstName >> tempLastName >> tempPin >> tempCash; //get input from file
User tempUser(tempId, tempFirstName, tempLastName, tempPin, tempCash); //use constructor to create a temp object
users[totalUsers] = tempUser; //assign temp object to a spot in our array
totalUsers++; //increment count for the next item
}
database.close();



do
{
cout<<"Welcome to da bank yo."<<endl
<<"Please enter your user id: ";
cin>>tempId;//get user id

cout<<"Please enter your 4-digit numerical pin: ";
cin>>tempPin;//get user pin

system("cls");//clear

activeUser = 0;

while(users[activeUser].isTrue(tempId, tempPin) == false && activeUser < totalUsers)
{

activeUser++;
system ("cls");
}

}while(activeUser == totalUsers);






cout<<"Welcome back "<<users[activeUser].getFirstName()<<" "<<users[activeUser].getLastName()<<", What would you like to do?"<<endl;
cout<<"1) View Account Info"<<endl
<<"2) Withdraw"<<endl
<<"3) Deposit"<<endl
<<"4) Change Pin"<<endl
<<"5) Quit"<<endl<<endl
<<"What action would you like to take? ";

cin>>ui;
system("cls");
while (ui != 5)
{
while (ui < 1 || ui > 5)
{
system("cls");

cout<<"Invalid Selection, Please Choose Again"<<endl<<endl;

cout<<"1) View Account Info"<<endl
<<"2) Withdraw"<<endl
<<"3) Deposit"<<endl
<<"4) Change Pin"<<endl
<<"5) Quit"<<endl<<endl
<<"What action would you like to take? ";

cin>>ui;
system("cls");
}


if (ui == 1)
{
cout<<"Name: "<<users[activeUser].getFirstName()
<<" "<<users[activeUser].getLastName()<<endl;
cout<<"ID: "<<users[activeUser].getId()<<endl;
cout<<"Dough: $"<<users[activeUser].getCash()<<endl;
}


if (ui == 2)//withdraw
{
cout<<"How Much would you like to withdraw?"<<endl<<"$ ";
cin>>withdraw;
users[activeUser].setWithdraw(withdraw);
}


if (ui == 3)//deposit
{
cout<<"How Much would you like to deposit?"<<endl<<"$ ";
cin>>deposit;
users[activeUser].setDeposit(deposit);
}


if (ui == 4)//pin change
{
users[activeUser].changePin(tempPin);
}


if (ui == 5)//exit
{

}

cout<<"1)Back to Main Menu?"<<endl
<<"2)Quit"<<endl;
cin>>ui2;

while(ui2 < 1 || ui2 > 2)
{
system("cls");
cout<<"Invalid selection."<<endl;
cout<<"1)Back to Main Menu?"<<endl
<<"2)Quit"<<endl;
cin>>ui2;
}
system("cls");

if(ui2 == 1)
{
cout<<"1) View Account Info"<<endl
<<"2) Withdraw"<<endl
<<"3) Deposit"<<endl
<<"4) Change Pin"<<endl
<<"5) Quit"<<endl<<endl
<<"What action would you like to take? ";

cin>>ui;
system("cls");
}

else
{
ui = 5; //exit loop
}
}



cout<<"Come back soon and gimme some more money."<<endl<<"GOODBYE"<<endl<<endl;


system ("pause");
return 0;
}


Last edited on
closed account (2UD8vCM9)
 
cout<<"Welcome to da bank yo."<<endl


Please don't tell me you really plan on turning this in.
hey there, i m new in c++ world and want help. i want to write a program of equations of motion. the program should be able to solve equations of motion i.e. user can provide values of Vf, Vi , a , t, and S
but user will not some of them, program should decide which equation is suitable and find out remaining variables. its about 3 days i m trying to do it bt i have problm to distinguish known and unknown values and how to use the suitable equation according to data provided.
kindly help me
new to programing but shouldn't this line near the end
1
2
3
{
 ui = 5;//exit loop
}
be else (ui == 2;) also removing the curly brace above and below the ui line. I think you are actually declaring ui as 5 not checking the value of it. I could be wrong tho
also when i compiled 119,122,124,126, and 130 also have an error
also the ; on 131 I dont think should be there
Last edited on
hira I am also new to programing but I would check out switch statments and have a display of like 1 known are Vf, Vi and input a formula and solve case 2 a, t input equation and solve , etc.. not sure of the formulas or how many variable are known or I would try to help more
op: please use code tags and cleary define your problem. what are the issues?
hira152: please don't hijack thread. start your own
sly: else statements cant have conditions
any of three variables would be given and eq.s of motion are:
vf=vi+at
S=vi*t+1/2(a*t^2)
2aS=vf^2 - vi^2


where a is accelaration,S is distance and vf and vi are final nd initial velocities
hira152: please stop hijacking this post. you are more than welcome to create a new one.
Topic archived. No new replies allowed.