8000 Om 🍉 · omroy07/C-CPP-Programming@651f0f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 651f0f7

Browse files
committed
Om 🍉
1 parent 650c802 commit 651f0f7

File tree

5 files changed

+146
-46
lines changed

5 files changed

+146
-46
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,83 @@
1-
// Autor : Nemonet TYP
1+
// Autor : OM ROY
22
// Title: A Login and Registration System Programmed in C++
33
// PROJECT FOR C/C++ PROGRAMMING TUTORIAL
44

5-
65
#include <iostream>
76
#include <fstream>
8-
#include <string.h>
9-
#include <vector>
10-
#include <functional>
11-
#include <cmath>
12-
#include <cstdlib>
7+
#include <string>
138
#include <ctime>
14-
#include "login.cpp"
9+
#include <random>
1510
using namespace std;
16-
17-
int main()
11+
bool checkCaptcha(string& captcha, string& user_captcha)
1812
{
19-
login userLogin;
20-
string userChoice;
21-
cout << "\t\t\t_____________________________________________\n\n\n";
22-
cout << "\t\t\t Welcome to the NEMO 2023 Login! \n\n";
23-
cout << "\t\t\t_________ Menu __________\n\n";
24-
cout << "\t | Press 1 to LOGIN |" << endl;
25-
cout << "\t | Press 2 to REGISTER |" << endl;
26-
cout << "\t | Press 3 if you forgot PASSWORD |" << endl;
27-
cout << "\t | Press 4 to EXIT |" << endl;
28-
cout << "\n\t\t\t Please Enter your choice: ";
29-
cin >> userChoice;
30-
cout << endl;
3113

32-
if (userChoice == "1")
33-
{
34-
userLogin.Login();
35-
main();
36-
}
37-
else if (userChoice == "2")
38-
{
39-
userLogin.Registration();
40-
main();
41-
}
42-
else if (userChoice == "3")
43-
{
44-
userLogin.ForgotPassword();
45-
main();
46-
}
47-
else if (userChoice == "4")
48-
{
49-
cout << "\t\t\t Goodbye! \n\n";
50-
}
14+
return captcha.compare(user_captcha) == 0;
15+
}
16+
string generateCaptcha(int n)
17+
{
18+
time_t t;
19+
srand((unsigned)time(&t));
20+
const char* chrs = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
21+
string captcha = "";
22+
while (n--)
23+
captcha.push_back(chrs[rand() % 62]);
24+
return captcha;
25+
}
26+
void registeruser() {
27+
string u, p;
28+
cout << "Enter username: ";
29+
cin >> u;
30+
cout << "Enter password: ";
31+
cin >> p;
32+
ofstream outfile("users.txt", ios::app);
33+
outfile << u << " " << p<< endl;
34+
outfile.close();
35+
cout << "Registration successful!" << endl;
36+
}
37+
bool login() {
38+
string u, p, su, sp;//su:-storedusername,sp:-storedpassword
39+
cout << "Enter username: ";
40+
cin >> u;
41+
cout << "Enter password: ";
42+
cin >> p;
43+
string captcha = generateCaptcha(9);
44+
cout << captcha;
45+
string usr_captcha;
46+
cout << "Enter above CAPTCHA: ";
47+
cin >> usr_captcha;
48+
if (checkCaptcha(captcha, usr_captcha))
49+
printf("\nCAPTCHA Matched\n");
5150
else
52-
{
53-
system("cls");
54-
cout << "\t\t\t Please select from the options above\n";
55-
main();
51+
printf("\nCAPTCHA Not Matched\n");
52+
ifstream infile("users.txt");
53+
while (infile >> su >>sp) {
54+
if (su == u && sp == p) {
55+
infile.close();
56+
return true;
57+
}
5658
}
59+
infile.close();
60+
return false;
5761
}
62+
63+
int main() {
64+
int c;
65+
cout << "Enter your choice(1.Registration,2.Login): ";
66+
cin >> c;
67+
if (c == 1) {
68+
registeruser();
69+
}
70+
else if (c == 2) {
71+
if (login()) {
72+
cout << "Login successful!" << endl;
73+
}
74+
else {
75+
cout << "Login failed!" << endl;
76+
}
77+
}
78+
else {
79+
cout << "Invalid !" << endl;
80+
}
81+
return 0;
82+
}
83+
10000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Autor : OM ROY
2+
// Title: Bank Management System Programmed in C++
3+
// PROJECT FOR C/C++ PROGRAMMING TUTORIAL
4+
5+
#include<iostream>
6+
#include<string>
7+
#include<cmath>
8+
using namespace std;
9+
class Bank {
10+
string name;
11+
double accountNumber, depositAmount, withdrawalAmount, balance, rate, timeDuration;
12+
char accountType;
13+
public:
14+
void getdata();
15+
void saving_account();
16+
void current_account();
17+
void display();
18+
};
19+
void Bank::getdata(void) {
20+
cout << "Enter the name of Account Holder: ";
21+
cin.ignore();
22+
getline(cin, name);
23+
cout << "Enter the Account Number: ";
24+
cin >> accountNumber;
25+
cout << "Enter the Deposit Amount: ";
26+
cin >> depositAmount;
27+
cout << "Enter the Withdrawal Amount: ";
28+
cin >> withdrawalAmount;
29+
balance = 0000; // Initial balance
30+
cout << "Enter the Account Type (s for saving, c for current): ";
31+
cin >> accountType;
32+
cout << "Enter the Time Duration (in years): ";
33+
cin >> timeDuration;
34+
switch(accountType) {
35+
case 's':
36+
saving_account();
37+
break;
38+
case 'c':
39+
current_account();
40+
break;
41+
default:
42+
cout << "Invalid account type!" << endl;
43+
}
44+
}
45+
void Bank::saving_account(void) {
46+
rate = 7;
47+
balance = balance + depositAmount - withdrawalAmount;
48+
double finalBalance = balance * pow((1 + rate / 100), timeDuration);
49+
cout << "The Balance after the compound interest: " << finalBalance << endl;
50+
cout << "The Amount after withdrawal: " << balance << endl;
51+
cout << "You will not get a check book." << endl;
52+
}
53+
void Bank::current_account(void) {
54+
rate = 5;
55+
balance = balance + depositAmount - withdrawalAmount;
56+
cout << "The Balance: " << balance << endl;
57+
if (balance >= 3000) {
58+
cout << "The ledger balance: " << balance << endl;
59+
} else {
60+
cout << "The ledger balance: " << balance - 354 << " (including penalty)" << endl;
61+
}
62+
cout << "You will get a check book." << endl;
63+
}
64+
void Bank::display(void) {
65+
cout << "The Account Holder Name: " << name << endl;
66+
cout << "Account Number: " << accountNumber << endl;
67+
cout << "Current Balance: " << balance << endl;
68+
}
69+
int main() {
70+
Bank account;
71+
account.getdata();
72+
account.display();
73+
return 0;
74+
}
75+
Binary file not shown.

Projects/C++ Projects/Basic/Bank Management System/main.cpp

-1
This file was deleted.
Binary file not shown.

0 commit comments

Comments
 (0)
0