Answer to Question #164504 in C++ for Vincent Mercado

Question #164504

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


1
Expert's answer
2021-02-17T14:55:20-0500
#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;    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment