Question
Question
#include <string>
int main() {
int choice;
cout << "Choose a country to see the number of space satellites sent:" << endl;
// Input validation
if (cin.fail()) {
cout << "Invalid input. Please enter a number between 1 and 4." << endl;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
return 1;
cout << "Invalid choice. Please enter a number between 1 and 4." << endl;
return 1;
}
int satellitesSent = 0;
switch (choice) {
case 1:
satellitesSent = 440;
break;
case 2:
satellitesSent = 250;
break;
case 3:
satellitesSent = 150;
break;
case 4:
satellitesSent = 100;
break;
if (satellitesSent > 0) {
cout << "Number of space satellites sent: " << satellitesSent << endl;
cout << "\nHow many non-working satellites are there? (Select a country)" << endl;
// Input validation
if (cin.fail()) {
cout << "Invalid input. Please enter a number between 1 and 4." << endl;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
return 1;
cout << "Invalid choice. Please enter a number between 1 and 4." << endl;
return 1;
int nonWorkingSatellites = 0;
switch (choice) {
case 1:
nonWorkingSatellites = 20;
break;
case 2:
nonWorkingSatellites = 60;
break;
case 3:
nonWorkingSatellites = 80;
break;
case 4:
nonWorkingSatellites = 80;
break;
if (nonWorkingSatellites > 0) {
cout << "Number of non-working satellites: " << nonWorkingSatellites << endl;
}
// Third Question: Space Debris in Planets
// Input validation
if (cin.fail()) {
cout << "Invalid input. Please enter a number between 1 and 3." << endl;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
return 1;
cout << "Invalid choice. Please enter a number between 1 and 3." << endl;
return 1;
int debrisCount = 0;
switch (choice) {
case 1:
debrisCount = 18;
break;
case 2:
debrisCount = 40;
break;
case 3:
debrisCount = 9;
break;
if (debrisCount > 0) {
cout << "Space debris count: " << debrisCount << endl;
cout << "Active satellites: " << activeSatellites << endl; // Now prints active satellites
return 0;