Remove tax from withdraw and deposit leave it only on work + add higher or lower game logic

This commit is contained in:
nyosic 2025-02-08 19:56:51 +01:00
parent b81d89a63c
commit d2853b7074
4 changed files with 103 additions and 30 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
.vscode/ .vscode/
.Makefile/

2
Makefile Normal file
View File

@ -0,0 +1,2 @@
all:
g++ -o main main.cpp

BIN
main

Binary file not shown.

View File

@ -7,6 +7,7 @@ using namespace std;
char end_choice; char end_choice;
int balance = 0; int balance = 0;
int bank_balance = 10000; int bank_balance = 10000;
int save_depo = 0;
void coinflip() { void coinflip() {
srand(time(0)); // Seed the random number generator srand(time(0)); // Seed the random number generator
@ -270,7 +271,77 @@ void diceRoll() {
void higherOrLower() { void higherOrLower() {
cout << "Higher or Lower game logic coming soon!" << endl; srand(time(0));
int bet_amount;
char outcome;
char end_choice;
cout << "Enter the amount of money you want to bet on higer or lower: ";
cin >> bet_amount;
int start_number = rand() % 100 + 1;
cout << "Starting number: " << start_number << endl;
cout << "Guess the outcome (H-Higher/L-Lower): ";
cin >> outcome;
if (bet_amount > balance) {
cout << "You don't have enough NyscoCoins! Please try again with a lower amount." << endl;
sleep(3);
higherOrLower();
}
if (outcome > 100 || outcome < 1) {
cout << "The range is from 1 to 100" << endl;
sleep(3);
higherOrLower();
}
balance -= bet_amount;
cout << "Generating the output number.." << endl;
sleep(2);
int end_number = rand() % 100 + 1;
if(start_number > end_number) {
cout << "You guessed: " << outcome << " (The outcome is: " << end_number << " and its lower!)" << endl;
}
else if(start_number < end_number) {
cout << "You guessed: " << outcome << " (The outcome is: " << end_number << " and its higher!)" << endl;
}
if (outcome == 'H' || outcome == 'h') {
if (start_number < end_number) {
cout << "Congratulations! You won double your bet amount!" << endl;
balance += 2 * bet_amount;
}
else {
cout << "You lost! Better luck next time!" << endl;
}
}
else if (outcome == 'L' || outcome == 'l') {
if (start_number > end_number) {
cout << "Congratulations! You won double your bet amount!" << endl;
balance += 2 * bet_amount;
}
else {
cout << "You lost! Better luck next time!" << endl;
}
}
cout << "Your new balance is: " << balance << " NyscoCoins" << endl;
cout << "Play again? (Y/N): ";
cin >> end_choice;
if (end_choice == 'y' || end_choice == 'Y') {
system("clear");
higherOrLower();
}
else {
system("clear");
}
} }
void deposit() { void deposit() {
@ -299,10 +370,9 @@ void withdraw() {
cin >> withdraw_amount; cin >> withdraw_amount;
if (balance >= withdraw_amount) { if (balance >= withdraw_amount) {
balance -= withdraw_amount; balance -= withdraw_amount;
bank_balance += withdraw_amount * 0.76; bank_balance += withdraw_amount;
system("clear"); system("clear");
cout << "Deposit successful! Your new bank balance is: " << bank_balance << "$ (after tax)" << endl; cout << "Deposit successful! Your new bank balance is: " << bank_balance << "$" << endl;
cout << "Gambling is also taxed!" << endl;
sleep(3); sleep(3);
system("clear"); system("clear");
} }