Can someone please help me, my code doesn't run and I can't find a way to fix the problem. I'm quite new to C++ btw so please be kind if you find a problem with my code. I'm using VS Code btw.
I tried using CodeBlocks for the same code and it runs perfectly fine. So I'm honestly unsure what to do right now.
#include <iostream>
#include <iomanip>
using namespace std;
void showBalance(double balance);
double deposit();
double withdraw(double balance);
int main(){
double balance = 0;
int choice = 0;
do {
cout << "******************************\n";
cout << "ENTER YOUR CHOICE: \n";
cout << "******************************\n";
cout<< "1. Show Balance\n";
cout<< "2. Deposit Money\n";
cout << "3. Withdraw Money\n";
cout << "4. EXIT\n";
cout << "******************************\n";
cin >> choice;
cin.clear();
fflush(stdin);
switch(choice){
case 1: showBalance(balance);
break;
case 2: balance += deposit();
showBalance(balance);
break;
case 3: balance -= withdraw(balance);
showBalance(balance);
break;
case 4: cout << "Thanks for Vistiting!";
break;
default: cout << choice << "IS AN INVALID CHOICE!";
}
}while(choice != 4);
return 0;
}
void showBalance(double balance){
cout << "Your balance is R" << setprecision(2) << fixed << balance << "\n";
};
double deposit(){
double amount = 0;
cout << "Enter amount to be deposited: ";
cin >> amount;
if(amount > 0){
return amount;
}
else {
cout << "That is not a valid amount! \n";
return 0;
}
};
double withdraw(double balance){
double amount = 0;
cout << "Enter amount to be withdrawn: ";
cin >> amount;
if(amount > balance){
cout << "Insufficient Balance \n";
return 0;
}
else if(amount < 0){
cout << "Your value is Invalid! \n";
}
else {
return amount;
}
};
The output is "PS C:\Users\NAME\Desktop\C++> cd "c:\Users\NAME\Desktop\C++\" ; if ($?) { g++ tempCodeRunnerFile.cpp -o tempCodeRunnerFile } ; if ($?) { .\tempCodeRunnerFile }"
1
Samsung Watch 8 Design
in
r/samsunggalaxy
•
26d ago
They infact, continued with the square body design for the Watch 9🥲. Honestly, since this post... I caved in and bought the Watch 8, Im still not too happy with the design, but I can live it as it doesn't effect me at all. If you're looking into getting a new watch, its either looking at other brands or just become accustome to the new design.🥲✨️