Write a program for the Air Force to label an aircraft as military or civilian. The program is to be given the plane’s observed speed in km/h and its estimated length in meters. For planes traveling in excess of 1100 km/h, and longer than 52 meters, you should label tem as “civilian” aircraft, and shorter such as 500 km/h and 20 meters as “military” aircraft. For planes traveling at slower speeds, you will issue an “It’s a bird” message. if else statement
#include <iostream>
int main()
{
int speed, length;
std::cout << "Please enter speed and length of aircraft: ";
std::cin >> speed >> length;
if(!std::cin || speed < 0 || length < 0)
{
std::cout << "Bad input\n";
return 1;
}
if(speed > 1100 && length > 52)
{
std::cout << "The aircraft is civilian\n";
}
else
if(speed > 500 && length > 20)
{
std::cout << "The aircraft is military\n";
}
else
{
std::cout << "It's a bird\n";
}
return 0;
}
Comments
Leave a comment