Untitled
unknown
plain_text
a month ago
1.0 kB
3
Indexable
Never
#include <iostream> #include <cstdlib> using namespace std; int main() { char input; int progress = 0; // Tracks progress (cleaning progress in this case) const int target = 10; // Target to reach for winning cout << "Welcome to the WASD Game!" << endl; cout << "Use 'W', 'A', 'S', or 'D' to make progress and clean the object!" << endl; cout << "You need to make " << target << " correct moves to win!" << endl; while (progress < target) { cout << "Enter W, A, S, or D: "; cin >> input; // Convert to uppercase to allow lowercase input as well input = toupper(input); if (input == 'W' || input == 'A' || input == 'S' || input == 'D') { progress++; cout << "Good move! Progress: " << progress << "/" << target << endl; } else { cout << "Invalid input! Use only 'W', 'A', 'S', or 'D'." << endl; } } cout << "Congratulations! You've cleaned the object!" << endl; return 0; }
Leave a Comment