From 69edc01908fff6de6c6e0f82249befaf18f4e827 Mon Sep 17 00:00:00 2001 From: Uday Vamsidhar <108140307+Uday-Vamsidhar@users.noreply.github.com> Date: Mon, 24 Oct 2022 18:45:20 +0530 Subject: [PATCH] Project Idea & Aid The repo is very good for beginners. I decided we can add a project section to make it a complete tutorial. --- Banking System.cpp | 194 +++++++++++++++++++++++++++++++++++ FirstTo21.cpp | 245 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 439 insertions(+) create mode 100644 Banking System.cpp create mode 100644 FirstTo21.cpp diff --git a/Banking System.cpp b/Banking System.cpp new file mode 100644 index 0000000..c499ef1 --- /dev/null +++ b/Banking System.cpp @@ -0,0 +1,194 @@ +#include +#include +#include +using namespace std; + +class bank +{ + float balance, rate; + + public: + + bank(float cash, float r) + { + usleep(1000000); + balance = cash; + rate = r; + cout << "Successfully opened your new account!" << endl; + usleep(1000000); + cout<<"\033[2J\033[1;1H"; + } + + void deposit() + { + usleep(1000000); + float d; + cout << "Enter the amount you want to deposit in your account: "; + cin >> d; + balance += d; + cout << "Successfully deposited the amount mentioned!" << endl; + } + + void withdraw() + { + usleep(1000000); + float withdrawal; + cout << "Enter the amount you want to withdraw from your account: "; + cin >> withdrawal; + if (balance - withdrawal < 1000) + cout << "Not enough cash available to withdraw" << endl; + else + { + balance -= withdrawal; + cout << "Successfully withdrawn the amount mentioned!" << endl; + } + } + + float calcinterest(int time) + { + usleep(1000000); + float amount; + amount = balance * pow((1 + (rate / 100)), time); + float interest = amount - balance; + balance = amount; + return interest; + } + + float getbalance() + { + usleep(1000000); + return balance; + } + + ~bank() + { + usleep(1000000); + cout << "Hence,successfully closed your account!" << endl; + } +}; + +class loan +{ + private: + int temp; + + public: + void approval(float credit_score, float loan_amount) + { + usleep(1000000); + temp=0; + if(loan_amount<1000) + cout<<"This loan amount is not available"<=10000000&&credit_score>=800) + { + cout<<"You are eligible for this loan."<=1000000&&credit_score>=650&&loan_amount<10000000) + { + cout<<"You are eligible for this loan."<=100000&&credit_score>=450&&loan_amount<1000000) + { + cout<<"You are eligible for this loan."<=10000&&credit_score>=300&&loan_amount<100000) + { + cout<<"You are eligible for this loan."<=1000&&credit_score>=200&&loan_amount<10000) + { + cout<<"You are eligible for this loan."<>credit_score; + cout<<"Enter the amount of loan you want to request - "; + cin>>loan_amount; + approval(credit_score,loan_amount); + } +}loan_class; + +int n = 0; +void menu(bank &ob) +{ + cout<<"\033[2J\033[1;1H"; + cout << "\tMENU\n"; + cout << "1.DEPOSIT MONEY\n"; + cout << "2.WITHDRAW MONEY\n"; + cout << "3.CALCULATE INTEREST\n"; + cout << "4.DISPLAY AVAILABLE BALANCE\n"; + cout << "5.CHECK LOAN APPROVAL\n"; + cout << "6.CLOSE ACCOUNT\n"; + int ch; + cin >> ch; + cout<<"\033[2J\033[1;1H"; + switch (ch) + { + case 1: + ob.deposit(); + usleep(1000000); + return; + case 2: + ob.withdraw(); + usleep(1000000); + return; + case 3: + int t; + cout << "Enter the time (in years) till when you want to keep the money in bank account: "; + cin >> t; + cout << "The interest you got is: " << ob.calcinterest(t) << endl; + usleep(1000000); + return; + case 4: + cout << "The current balance is: " << ob.getbalance() << endl; + usleep(1000000); + return; + case 5: + loan_class.loan_approval(); + usleep(1000000); + return; + case 6: + n = 1; + usleep(1000000); + return; + } +} + +// Driver Code +int main() +{ + cout<<"\033[2J\033[1;1H"; + int cash, rate; + cout << "Let's open the bank account first!\n"; + usleep(1000000); + cout << "Enter initial balance: "; + cin >> cash; + cout << "Enter the rate of interest of the bank: "; + cin >> rate; + bank account(cash, rate); + while (1) + { + menu(account); + if (n == 1) + break; + } + return 0; +} \ No newline at end of file diff --git a/FirstTo21.cpp b/FirstTo21.cpp new file mode 100644 index 0000000..34f30cf --- /dev/null +++ b/FirstTo21.cpp @@ -0,0 +1,245 @@ +//DONE :*) +#include +#include +using namespace std; +int main(); +int x=0; +int cv,ccv; +int hv,chv; +int human(int chv,int x) +{ + cout<<"What would you add ? "; + cin>>chv; + if((chv>=1&&chv<=3)&&(x+chv<=21)) + return chv; + else + { + cout<<"Woah, that number can't be added, dont worry you can try again"<=1&&ccv<=3)) + return ccv; + else + cpumod(ccv,x); + } +} +int cpuhard(int ccv,int x) +{ + if(x+1==21||x+1==13||x+1==17||x+1==9||x+1==5) + return 1; + else if(x+2==21||x+2==13||x+2==17||x+2==9||x+2==5) + return 2; + else if(x+3==21||x+3==13||x+3==17||x+3==9||x+3==5) + return 3; + else + { + ccv=rand()%10; + if(ccv<=3&&ccv>=1) + return ccv; + else + cpuhard(ccv,x); + } +} +int cpueasy(int ccv, int x) +{ + if(x+1==21) + return 1; + else if(x+2==21) + return 2; + else if(x+3==21) + return 3; + else + { + ccv=rand()%10; + if(ccv>=1&&ccv<=3) + return ccv; + else + cpueasy(ccv,x); + } +} +void checkhum(int x) +{ + if(x==21) + { + cout<>choice; + if(choice=="yes"||choice=="YES"||choice=="Yes") + main(); + else + { + cout<>choice; + if(choice=="yes"||choice=="YES"||choice=="Yes") + main(); + else + { + cout<Its a simple game where you must get to 21 before your opponent"<You start the game with 0"<You can add 1,2 or 3 only in your turn"<Don't mind the cpu trash talking :P"<Good Luck and have Fun :)"<>chose; + if(chose==1) + easy(x,hv,chv,cv,ccv); + else if(chose==2) + mod(x,hv,chv,cv,ccv); + else if(chose==3) + hard(x,hv,chv,cv,ccv); + else + { + cout<