0% found this document useful (0 votes)
1 views5 pages

Question

The document is a C++ program that prompts the user to select a country and provides information on the number of space satellites sent and the number of non-working satellites. It also allows the user to inquire about space debris on specific planets, including Mars, Venus, and Jupiter. The program includes input validation to ensure the user enters valid choices.

Uploaded by

kthamayanthi8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views5 pages

Question

The document is a C++ program that prompts the user to select a country and provides information on the number of space satellites sent and the number of non-working satellites. It also allows the user to inquire about space debris on specific planets, including Mars, Venus, and Jupiter. The program includes input validation to ensure the user enters valid choices.

Uploaded by

kthamayanthi8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

#include <iostream>

#include <string>

#include <limits> // for numeric_limits

using namespace std;

int main() {

int choice;

// First Question: Number of Space Satellites Sent

cout << "Choose a country to see the number of space satellites sent:" << endl;

cout << "1. India" << endl;

cout << "2. USA" << endl;

cout << "3. China" << endl;

cout << "4. Japan" << endl;

cout << "Enter your choice (1-4): ";

cin >> choice;

// 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;

if (choice < 1 || choice > 4) {

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;

// Second Question: Non-Working Satellites

cout << "\nHow many non-working satellites are there? (Select a country)" << endl;

cout << "1. India" << endl;

cout << "2. USA" << endl;

cout << "3. China" << endl;

cout << "4. Japan" << endl;

cout << "Enter your choice (1-4): ";

cin >> choice;

// 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;

if (choice < 1 || choice > 4) {

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

cout << "\nSpace debris in which planet?" << endl;

cout << "1. Mars" << endl;

cout << "2. Venus" << endl;

cout << "3. Jupiter" << endl;

cout << "Enter your choice (1-3): ";

cin >> choice;

// 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;

if (choice < 1 || choice > 3) {

cout << "Invalid choice. Please enter a number between 1 and 3." << endl;

return 1;

int debrisCount = 0;

int activeSatellites = 0; // Add this line

switch (choice) {

case 1:

debrisCount = 18;

activeSatellites = 7; // Add this line

break;

case 2:
debrisCount = 40;

break;

case 3:

debrisCount = 9;

break;

if (debrisCount > 0) {

cout << "Space debris count: " << debrisCount << endl;

if (choice == 1) { // Check if it's Mars

cout << "Active satellites: " << activeSatellites << endl; // Now prints active satellites

return 0;

You might also like