When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
32 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
!code
```cpp
int main() {}
```
int main() {}
!f
#include <Windows.h>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace ::std;
int main() {
system("CLS");
int balance = 60;
wcout << "car 1 = $90" << endl << "car 2 = $20" << endl;
string mainMenu;
while (mainMenu != "q") {
getline(cin, mainMenu);
if (mainMenu == "car 1") {
if (balance < 90) {
wcout << "you can't afford this car" << endl;
} else if (balance > 90) {
wcout << "you have purchased car 1!" << endl
<< "new balance: " << balance - 90 << endl;
} else {
wcout << "you have purchased car 1!" << endl
<< "new balance: " << balance - 90 << endl;
}
}
else if (mainMenu == "car 2") {
if (balance < 20) {
wcout << "you can't afford this car" << endl;
} else if (balance > 20) {
wcout << "you have purchased car 2!" << endl
<< "new balance: " << balance - 20 << endl;
} else {
wcout << "you have purchased car 2!" << endl
<< "new balance: " << balance - 20 << endl;
}
}
}
}
dont include windows.h and don't use system please
It is supposed to update the balance after every purchase, it only updates the original balance
You update them using =.
balance = balance - 20;
std::cout << "your new balance is " << balance << '\n';
The first line can be shortened to balance -= 20;
instead of balance - 90 do balance -= 90
balance -= 90 subtracts 90 from the balance and returns the value
Thank you
;compile -includeiostream
int balance = 100;
std::cout << (balance -= 90);
10
Doing std::cout << "your new balance is " << (balance -= 20) << '\n'; works too, as nevemlaci said, but it's kinda cursed
you can tag me lol im here c:
Didn't want to 😛
@tidal scarab
@tidal scarab
kinda?
its very cursed 
@ nevemlaci
@near ore
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.
!solved
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
std::cout << "your new balance is " << (--(--(--(--(--(--(--(--(--(--(--(--(--(--(--(--(--(--(--(--balance)))))))))))))))))))) << '\n';

----------------------balance?

Is there a safer way to do what system("CLS") does
std::cout << "\033[2J\033[1;1H";