hi , i have a binking system project i have to use - Built-in functions User-def
ID: 3766709 • Letter: H
Question
hi , i have a binking system project
i have to use
- Built-in functions
User-define functions
One and two dimensional arrays
Search and sort algorithms
Static, local and global variables
Vectors
Files
it will do the follow
* Add a new account.
* Delete an existing account.
* Deposit
* Withdraw
* balance transfer
*balance inquiry
i start with this for now and i need to finsh withen 2 days max
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include<conio.h>
using namespace std;
int index1,index2;
int main()
{
vector< string> names ;
names.push_back( "mohammad" ) ; names.push_back( "khaled" ) ; names.push_back( "ahmmad" ) ;
vector<int> passwords ;
passwords.push_back(3421) ; passwords.push_back(1416) ; passwords.push_back(2776) ;
vector<int>acount;
acount.push_back(1000);acount.push_back(1000);acount.push_back(1000);
assert( passwords.size() == names.size() ) ;
//get name and password , login
bool x=true;
while(x=true)
{
cout << "name? " ;
string user_name ;
getline( cin, user_name ) ;
cout << "password? " ;
int pword ;
cin >> pword ;
// find the position corresponding to the name
int pos ;
for( pos = 0 ; pos < names.size() && names[pos] != user_name ; ++pos ) ;
if( pos < names.size() )
// if the name was found, pos would be less than names.size()
if( pos < names.size() && passwords[pos] == pword )
{
cout << "login successful " ;
index1=pos;
break;
}
else
{
cout << "invalid name/password " ;
x=true;
}
}
cout << "name? " ;
string user_name2 ;
getline( cin, user_name2 ) ;
int pos2;
for( pos2 = 0 ; pos2 < names.size() && names[pos2] != user_name2 ; ++pos2 ) ;
if( pos2 < names.size() )
index2=pos2;
cout<<index1<<endl<<index2;
getch();
return 0;
}
a few error in my code , the while loop infnit for some reason ,plz help
and please no classes of any kind
thak you .
Explanation / Answer
*************************************************************** HEADER FILE USED IN PROJECT **************************************************************** #include #include #include #include using namespace std; *************************************************************** CLASS USED IN PROJECT **************************************************************** class account { int acno; char name[50]; int deposit; char type; public: void create_account(); //function to get data from user void show_account() const; //function to show data on screen void modify(); //function to add new data void dep(int); //function to accept amount and add to balance amount void draw(int); //function to accept amount and subtract from balance amount void report() const; //function to show data in tabular format int retacno() const; //function to return account number int retdeposit() const; //function to return balance amount char rettype() const; //function to return type of account }; //class ends here void account::create_account() { coutacno; coutdeposit; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.