What's new

Closed At dahil walang nakakuha ng java programming namin ipina assignment nalang

Status
Not open for further replies.
S81018-182411.jpg Ito po
 

Attachments

Oo modulos 2 if remainder is 1 then odd if 0 then even.

#include <iostream>
#include<time.h>
#include <windows.h>
#include <stdlib.h>

using namespace std;

int passVer();
int Deposit();
int wí†hdráw();
int Balance();
int menu();
int bal = 10000;
int main()
{
passVer();

}
int passVer()
{
int no=0; // Number of usaers
cout<<"\n-----------------------\n";
cout<<" Welcome to DSA Bank\n";
cout<<"-----------------------\n";
system("pause");
system("cls");
cout<<"\n-----------------------\n";
cout<<"Enter number of user : ";
cin>>no;//Number of rows
cout<<"-----------------------\n";
string user[no][2];
for(int row=0; row<no; row++)
{
cout<<"\n-------------------------------------\n";
for(int col=0; col<2; col++)
{
cout<<"Enter username for account ["<<row<<"]: ";
cin>>user[row][col];
col++;
cout<<"Enter password for user ["<<row<<"] : ";
cin>>user[row][col];
}


}
cout<<"------------------------------------"<<endl;
cout<<"\tList of Users"<<endl;
cout<<"No \tUsername \tPassword"<<endl;
cout<<"------------------------------------"<<endl;
for(int row1=0; row1<no; row1++)
{
cout<<row1<<"\t";
for (int col1=0; col1<2; col1++)
{
cout<<user[row1][col1]<<"\t \t";
}
cout<<endl;
}

int acc=0 ;
string accn, accp;
system("cls");
system("pause");
cout<<"-------------------------\n";
cout<<"\nEnter account number : ";
cin>>acc;
cout<<"-------------------------\n";
if (acc >=0 && acc <no)
{
cout<<"Enter username for account "<<acc<<" : ";
cin>>accn;
cout<<"Enter username for account "<<acc<<" : ";
cin>>accp;
if (accn == user[acc][0] && accp == user [acc][1] )
{
system("cls");
cout<<"\n-----Log in Successful-----";
menu();
}
else
{

system("cls");
cout<<"Invalid";
Sleep(10000);
passVer();
}

}
else
{
system("cls");
cout<<"Invalid";
Sleep(10000);
passVer();
}
}

int menu( )
{

char cho, cho1;
cout<<"\n[A] - Deposit \n";
cout<<" - wí†hdráw\n";
cout<<"[C] - Check Balance\n[X] - Back";
cout<<"\nEnter your choice : ";
cin>>cho;
if (cho=='A' || cho=='a')
{
Deposit();
cout<<"Do you want another transaction [Y]yes [N]no : ";
cin>>cho1;
if (cho1 == 'Y' || cho1== 'y')
{
menu();
}
else
{
exit(0);
}
}
else if (cho=='B' || cho=='b')
{
wí†hdráw();
cout<<"Do you want another transaction [Y]yes [N]no : ";
cin>>cho1;
if (cho1 == 'Y' || cho1== 'y')
{
menu();
}
else
{
exit(0);
}
}
else if (cho=='C'|| cho=='c')
{
Balance();
cout<<"Do you want another transaction [Y]yes [N]no : ";
cin>>cho1;
if (cho1 == 'Y' || cho1== 'y')
{
menu();
}
else
{
exit(0);
}
}
else if (cho == 'X'|| cho=='x')
{
passVer();
}
else
{
exit(0);
}
}


int Deposit()
{
system("cls");
int dep = 0;
cout<<"-----------------------\n";
cout<<"Enter Amount to deposit : ";
cin>>dep;
cout<<"-----------------------\n";
bal = bal + dep;
}
int wí†hdráw()
{
system("cls");
int wid = 0;
cout<<"-----------------------\n";
cout<<"Enter Amount to wí†hdráw : ";
cin>>wid;
cout<<"-----------------------\n";
if (wid > 100 && wid % 100 == 0)
{
bal = bal - wid;
}
else
{
cout<<"Invalid Amount ";
menu();
}

}
int Balance( )
{
system("cls");
cout<<"-----------------------\n";
cout<<"Your balance is "<<bal<<"\n";
cout<<"-----------------------\n";
}
 
#include <iostream>
#include<time.h>
#include <windows.h>
#include <stdlib.h>

using namespace std;

int passVer();
int Deposit();
int wí†hdráw();
int Balance();
int menu();
int bal = 10000;
int main()
{
passVer();

}
int passVer()
{
int no=0; // Number of usaers
cout<<"\n-----------------------\n";
cout<<" Welcome to DSA Bank\n";
cout<<"-----------------------\n";
system("pause");
system("cls");
cout<<"\n-----------------------\n";
cout<<"Enter number of user : ";
cin>>no;//Number of rows
cout<<"-----------------------\n";
string user[no][2];
for(int row=0; row<no; row++)
{
cout<<"\n-------------------------------------\n";
for(int col=0; col<2; col++)
{
cout<<"Enter username for account ["<<row<<"]: ";
cin>>user[row][col];
col++;
cout<<"Enter password for user ["<<row<<"] : ";
cin>>user[row][col];
}


}
cout<<"------------------------------------"<<endl;
cout<<"\tList of Users"<<endl;
cout<<"No \tUsername \tPassword"<<endl;
cout<<"------------------------------------"<<endl;
for(int row1=0; row1<no; row1++)
{
cout<<row1<<"\t";
for (int col1=0; col1<2; col1++)
{
cout<<user[row1][col1]<<"\t \t";
}
cout<<endl;
}

int acc=0 ;
string accn, accp;
system("cls");
system("pause");
cout<<"-------------------------\n";
cout<<"\nEnter account number : ";
cin>>acc;
cout<<"-------------------------\n";
if (acc >=0 && acc <no)
{
cout<<"Enter username for account "<<acc<<" : ";
cin>>accn;
cout<<"Enter username for account "<<acc<<" : ";
cin>>accp;
if (accn == user[acc][0] && accp == user [acc][1] )
{
system("cls");
cout<<"\n-----Log in Successful-----";
menu();
}
else
{

system("cls");
cout<<"Invalid";
Sleep(10000);
passVer();
}

}
else
{
system("cls");
cout<<"Invalid";
Sleep(10000);
passVer();
}
}

int menu( )
{

char cho, cho1;
cout<<"\n[A] - Deposit \n";
cout<<" - wí†hdráw\n";
cout<<"[C] - Check Balance\n[X] - Back";
cout<<"\nEnter your choice : ";
cin>>cho;
if (cho=='A' || cho=='a')
{
Deposit();
cout<<"Do you want another transaction [Y]yes [N]no : ";
cin>>cho1;
if (cho1 == 'Y' || cho1== 'y')
{
menu();
}
else
{
exit(0);
}
}
else if (cho=='B' || cho=='b')
{
wí†hdráw();
cout<<"Do you want another transaction [Y]yes [N]no : ";
cin>>cho1;
if (cho1 == 'Y' || cho1== 'y')
{
menu();
}
else
{
exit(0);
}
}
else if (cho=='C'|| cho=='c')
{
Balance();
cout<<"Do you want another transaction [Y]yes [N]no : ";
cin>>cho1;
if (cho1 == 'Y' || cho1== 'y')
{
menu();
}
else
{
exit(0);
}
}
else if (cho == 'X'|| cho=='x')
{
passVer();
}
else
{
exit(0);
}
}


int Deposit()
{
system("cls");
int dep = 0;
cout<<"-----------------------\n";
cout<<"Enter Amount to deposit : ";
cin>>dep;
cout<<"-----------------------\n";
bal = bal + dep;
}
int wí†hdráw()
{
system("cls");
int wid = 0;
cout<<"-----------------------\n";
cout<<"Enter Amount to wí†hdráw : ";
cin>>wid;
cout<<"-----------------------\n";
if (wid > 100 && wid % 100 == 0)
{
bal = bal - wid;
}
else
{
cout<<"Invalid Amount ";
menu();
}

}
int Balance( )
{
system("cls");
cout<<"-----------------------\n";
cout<<"Your balance is "<<bal<<"\n";
cout<<"-----------------------\n";
}
 
Sa reply box, may "+" sign dun, click mo yun tapos select code. Tapos ipaste mo dun yung code mo.
Code:
#include <iostream>
#include<time.h>
#include <windows.h>
#include <stdlib.h>

using namespace std;

int passVer();
int Deposit();
int wí†hdráw();
int Balance();
int menu();
int bal = 10000;
int main()
{
passVer();

}
int passVer()
{
int no=0; // Number of usaers
cout<<"\n-----------------------\n";
cout<<" Welcome to DSA Bank\n";
cout<<"-----------------------\n";
system("pause");
system("cls");
cout<<"\n-----------------------\n";
cout<<"Enter number of user : ";
cin>>no;//Number of rows
cout<<"-----------------------\n";
string user[no][2];
for(int row=0; row<no; row++)
{
cout<<"\n-------------------------------------\n";
for(int col=0; col<2; col++)
{
cout<<"Enter username for account ["<<row<<"]: ";
cin>>user[row][col];
col++;
cout<<"Enter password for user ["<<row<<"] : ";
cin>>user[row][col];
}


}
cout<<"------------------------------------"<<endl;
cout<<"\tList of Users"<<endl;
cout<<"No \tUsername \tPassword"<<endl;
cout<<"------------------------------------"<<endl;
for(int row1=0; row1<no; row1++)
{
cout<<row1<<"\t";
for (int col1=0; col1<2; col1++)
{
cout<<user[row1][col1]<<"\t \t";
}
cout<<endl;
}

int acc=0 ;
string accn, accp;
system("cls");
system("pause");
cout<<"-------------------------\n";
cout<<"\nEnter account number : ";
cin>>acc;
cout<<"-------------------------\n";
if (acc >=0 && acc <no)
{
cout<<"Enter username for account "<<acc<<" : ";
cin>>accn;
cout<<"Enter username for account "<<acc<<" : ";
cin>>accp;
if (accn == user[acc][0] && accp == user [acc][1] )
{
system("cls");
cout<<"\n-----Log in Successful-----";
menu();
}
else
{

system("cls");
cout<<"Invalid";
Sleep(10000);
passVer();
}

}
else
{
system("cls");
cout<<"Invalid";
Sleep(10000);
passVer();
}
}

int menu( )
{

char cho, cho1;
cout<<"\n[A] - Deposit \n";
cout<<" - wí†hdráw\n";
cout<<"[C] - Check Balance\n[X] - Back";
cout<<"\nEnter your choice : ";
cin>>cho;
if (cho=='A' || cho=='a')
{
Deposit();
cout<<"Do you want another transaction [Y]yes [N]no : ";
cin>>cho1;
if (cho1 == 'Y' || cho1== 'y')
{
menu();
}
else
{
exit(0);
}
}
else if (cho=='B' || cho=='b')
{
wí†hdráw();
cout<<"Do you want another transaction [Y]yes [N]no : ";
cin>>cho1;
if (cho1 == 'Y' || cho1== 'y')
{
menu();
}
else
{
exit(0);
}
}
else if (cho=='C'|| cho=='c')
{
Balance();
cout<<"Do you want another transaction [Y]yes [N]no : ";
cin>>cho1;
if (cho1 == 'Y' || cho1== 'y')
{
menu();
}
else
{
exit(0);
}
}
else if (cho == 'X'|| cho=='x')
{
passVer();
}
else
{
exit(0);
}
}


int Deposit()
{
system("cls");
int dep = 0;
cout<<"-----------------------\n";
cout<<"Enter Amount to deposit : ";
cin>>dep;
cout<<"-----------------------\n";
bal = bal + dep;
}
int wí†hdráw()
{
system("cls");
int wid = 0;
cout<<"-----------------------\n";
cout<<"Enter Amount to wí†hdráw : ";
cin>>wid;
cout<<"-----------------------\n";
if (wid > 100 && wid % 100 == 0)
{
bal = bal - wid;
}
else
{
cout<<"Invalid Amount ";
menu();
}

}
int Balance( )
{
system("cls");
cout<<"-----------------------\n";
cout<<"Your balance is "<<bal<<"\n";
cout<<"-----------------------\n";
}
 
Code:
#include <iostream>
#include<time.h>
#include <windows.h>
#include <stdlib.h>

using namespace std;

char cho1; // sa mainmenu tinawag
char choice;
char welcomefunction;

string name = "";

double wí†hdráwAmount;
double depositAmount;
double salary;
double initialBal = 10000;

int dep;
int deposit();
int wí†hdráw();
int login();
int registeR();
int mainmenu();
int welcome();

int no;

main()
    {
        mainmenu();
    }


int mainmenu()
{
    cout << "testing midterm v.1" << endl;
    cout << "---------------------" << endl;
    cout << "hello, what would you like to do ? \n \n" << endl;
    cout << "[a] account registration" << endl;
    cout << "[b] log in" << endl;
    cout << "[c] transaction history" <<endl;
    cout << "[d] account list \n" << endl;
    cin >> choice;

if (choice =='a' || choice == 'A')
        {
            system("cls");
            registeR();
            cout<<" \nDo you want to register another account ? [Y]yes [N]no : ";
            cin>>cho1;
            if (cho1 == 'Y' || cho1== 'y')
            {
                registeR();
            }
            else
            {
               mainmenu();
            }
        }
    else if (choice == 'b' || choice == 'B')
        {
            int login();
        }
    else if (choice =='c' || choice == 'C')
        {
           int balance();
            cout<<"Do you want another transaction [Y]yes [N]no : ";
            cin>>cho1;
            if (cho1 == 'Y' || cho1== 'y')
            {
                welcome();
            }
            else
            {
                exit(0);
            }
        }
    else if (choice =='d' || choice == 'D')
        {
            int passVer(); // accout list
        }
        else
        {
            exit(0);
        }
}
registeR()
{
    int acc = 0;
    string accn, accp;

        cout<<"enter number of account you want to register : ";
        cin>>no;//Number of rows
        cout<<"-----------------------\n";
        string user[no][2];
        for(int row=0; row<no; row++)
    {
            cout<<"\n-------------------------------------\n";
            for(int col=0; col<2; col++)
        {
            cout<<"Enter username for account ["<<row<<"]: ";
            cin>>user[row][col];
            col++;
            cout<<"Enter password for user ["<<row<<"] : ";
            cin>>user[row][col];
        }


    }
        system("cls");
        cout<<"------------------------------------"<<endl;
        cout<<"\tList of Users"<<endl;
        cout<<"No \tUsername \tPassword"<<endl;
        cout<<"------------------------------------"<<endl;

        for(int row1=0; row1<no; row1++)
    {
            cout<<row1<<"\t";
            for (int col1=0; col1<2; col1++)
        {
            cout<<user[row1][col1]<<"\t \t";
        }
            cout<<endl;
    }
        system("pause");
        system("cls");
    cout << "do you want to register another account [Y]yes [N]no :?" <<endl;
    cin >> cho1;
            if (cho1 == 'Y' || cho1== 'y')
            {
                no++;
                registeR();
            }
            if (cho1 == 'N' || cho1 == 'n')
            {
                mainmenu();
            }
            else
            {
                cout << "invalid" <<endl;
                exit(0);
            }

    cout<<"-------------------------\n";
    cout<<"\nEnter account number : ";
    cin>>acc;
    cout<<"-------------------------\n";
    if (acc >=0 && acc <no)
    {
        cout<<"Enter username for account "<<acc<<" : ";
        cin>>accn;
        cout<<"Enter username for account "<<acc<<" : ";
        cin>>accp;
        if (accn == user[acc][0] && accp == user [acc][1] )
        {
            system("cls");
            cout<<"\n-----Log in Successful-----";
           welcome();
        }
        else
        {

            system("cls");
            cout<<"Invalid";
            Sleep(10000);
            mainmenu();
        }

    }
    else
    {
        system("cls");
        cout<<"Invalid";
        Sleep(10000);
        mainmenu();
    }
}
int history()
{
   int a;
    cout << "enter number of employee" << endl;
    cin >> a ;


    struct employee
    {
        string name = "";
        double rate;
        double number;
        double hours;
        double salary;

        employee *next;
    };

    employee*head;
    head=NULL;

    string inpName = "";
    double inpRate, inpHours, inpNumber;


    for (int ctr = 1; ctr<=a; ctr ++)
        {
            cout <<"enter employee number" << " : ";
            cin >> inpNumber;
            cout << "enter name" << ctr << " : ";
            cin.ignore();
            getline(cin,inpName);
            cout << "enter rate" << ctr << " : ";
            cin >> inpRate;
            cout << "enter hours" << ctr << " : ";
            cin >> inpHours;

            employee *newEmployee;
            employee *employeePointer;
            newEmployee = new employee;
            newEmployee -> name=inpName;
            newEmployee -> rate=inpRate;
            newEmployee -> number=inpNumber;
            newEmployee -> hours=inpHours;
            newEmployee -> salary=inpHours*inpRate;
            newEmployee -> next = NULL;

            if (head==NULL)
                {
                    head = newEmployee;
                }
            else
                {
                    employeePointer = head;

                    while (employeePointer -> next)
                    {
                        employeePointer = employeePointer ->next;
                    }
                    employeePointer -> next = newEmployee;
                }

        }
    employee *displayPointer;
    displayPointer = head;

            cout<<"-----------------------------------------"<<endl;
            cout<<"-----------------------------------------"<<endl;
            cout<<"*****EMPLOYEE LIST*****"<<endl;
            cout<<"-----------------------------------------"<<endl;
            cout<<"-----------------------------------------"<<endl;

            cout <<"number \t";
            cout <<"name \t";
            cout <<"rate \t";
            cout <<"hours \t";
            cout <<"salary \t";
            cout <<endl;

    while (displayPointer)
        {
            cout <<displayPointer ->number << " \t";
            cout <<displayPointer ->name << "\t";
            cout <<displayPointer ->rate << " \t";
            cout <<displayPointer ->hours << "\t";
            cout <<displayPointer ->salary<<"\t";

            displayPointer = displayPointer -> next;
            cout << endl;
        }
    system ("pause");
}
welcome()
    {
        cout << "----------------------" <<endl;
        cout << "what transaction do you want ?" << endl;
        cout << "[a]deposit" << endl;
        cout << "[b]wí†hdráw" << endl;
        cout << "[c]check balance" << endl;
        cout << "[d]homepage" << endl;
        cout << "[e]exit" << endl;
        cout << "\n enter choice" << endl;
        cin >>welcomefunction;
    }
int deposit()
{
    system("cls");
    int dep = 0;
    cout<<"-----------------------\n";
    cout<<"Enter Amount to deposit : ";
    cin>>depositAmount;
    cout<<"-----------------------\n";
    initialBal = initialBal + depositAmount;
}
int wí†hdráw()
{
    system("cls");
    int wid = 0;
    cout<<"-----------------------\n";
    cout<<"Enter Amount to wí†hdráw : ";
    cin>>wí†hdráwAmount;
    cout<<"-----------------------\n";
    if (wid > 100 && wid % 100 == 0)
    {
        initialBal = initialBal - wí†hdráwAmount;
    }
    else
    {
        cout<<"Invalid Amount ";
        welcome();
    }

}
int balance( )
{
    system("cls");
    cout<<"-----------------------\n";
    cout<<"Your balance is "<<initialBal<<"\n";
    cout<<"-----------------------\n";
}
 
Yung log in function talaga paps Di makuha... Need ko pang mag struct di ko pa naaayos
Kailangan mo lang ng true or false dun.
May loggedIn = false ka.
Tapos sa log in. Kapag tama yung input. set mo loggedIn = true.
So sa mga ibang process mo. Icheheck mo muna kung loggedIn is true.
Ang problem. Kailangan maglogout para ma set mo ulit sa false yung loggedIn.
Basta ganun ang idea.
 
Status
Not open for further replies.
Back
Top