Question

In: Computer Science

****user comments: PLEASE READ INSTRUCTIONS THOROUGHLY AND KEEP THE STRUCTURE OF THE PROGRAM. JUST ADD THE...


****user comments: PLEASE READ INSTRUCTIONS THOROUGHLY AND KEEP THE STRUCTURE OF THE PROGRAM. JUST ADD THE ADDITIVES NEEDED
IN ORDER TO SUFFICE THE PROGRAM. PLEASE MAKE SURE IT IS IN C++ AND WORKS! THANK YOU!****

Write a program that uses a structure to store the following information for a particular month at the local airport:

Total number of planes that landed
Total number of planes that departed
Greatest number of planes that landed in a given day that month
Least number of planes that landed in a given day that month

The program should have an array of twelve structures to hold travel information for the entire year.
The program should prompt the user to enter data for each month.
Once all data is entered, the program should calculate and output the aver- age monthly number of landing planes,
the average monthly number of depart- ing planes, the total number of landing and departing planes for the year,
and the greatest and least number of planes that landed on any one day (and which month it occurred in).

PROGRAM NEEDED EDITING:

// This program uses a structure to hold data about an airport.

// PLACE YOUR NAME HERE

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

struct airport // defines the structure airport
{
int landed; // planes landed in a month
int departed; // planes departured in a month
int mostLanded; // greatest number of planes landed in one day in the month
int leastLanded; // least number of planes landed in one day in the month
};

const int MAXMONTH = 12;

int main()
{
airport planes[MAXMONTH];
int pos; // loop counter
int totalLandings = 0; // Total landings in the year
int totalDeparted = 0; // Total departures in a year
int mostLandings = 0; // Day of most landings
int leastLandings = 99999; // Day of least landings
string monthMost; // Month that had most single day landings
string monthLeast; // Month that had least single day landings
string month;

//add for loop to count through array
//use a switch to determine month

cout << "Please enter the number of planes that landed in " << month << ": ";
cin >> planes[pos].landed;

cout << "Please enter the number of planes that departed in " << month << ":";
cin >> //add code here

cout << "Please enter the greatest number of planes that landed on a single day in "
<< month << ": ";
cin >> //add code here

cout << "Please enter the least number of planes that landed on a single day in "
<< month << ": ";
cin >> //add code here

totalLandings = //add code here
totalDeparted = //add code here

if (mostLandings < planes[pos].mostLanded)
{
mostLandings = //add code here
monthMost = month;
}

if (leastLandings > planes[pos].leastLanded)
{
leastLandings = //add code here
monthLeast = month;
}
}

cout << setprecision(2) << fixed << showpoint;

cout << "The average monthly landings for the year is "
<< (float)totalLandings/MAXMONTH << endl;

cout << "The average monthly departures for the year is "
<< (float)totalDeparted/MAXMONTH << endl;

cout << "The total landings for the year is " << totalLandings << endl;
cout << "The total departures for the year is " << totalDeparted << endl;

cout << "The greatest number of planes that landed in a single day is "
<< mostLandings << " which occured in the month of " << monthMost << endl;

cout << "The least number of planes that landed in a single day is "
<< leastLandings << " which occured in the month of " << monthLeast << endl;

return 0;
}

Solutions

Expert Solution

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

struct airport // defines the structure airport
{
   int landed; // planes landed in a month
   int departed; // planes departured in a month
   int mostLanded; // greatest number of planes landed in one day in the month
   int leastLanded; // least number of planes landed in one day in the month
};

const int MAXMONTH = 12;

int main()
{
   airport planes[MAXMONTH];
   int pos; // loop counter
   int totalLandings = 0; // Total landings in the year
   int totalDeparted = 0; // Total departures in a year
   int mostLandings = 0; // Day of most landings
   int leastLandings = 99999; // Day of least landings
   string monthMost; // Month that had most single day landings
   string monthLeast; // Month that had least single day landings
   string month;
  
   //add for loop to count through array
   //use a switch to determine month
   for(pos=0;pos<MAXMONTH;pos++)
   {
       //switch to determine month
       switch(pos)
       {
           case 0:
               month="January";
               break;
           case 1:
               month="February";
               break;
           case 2:
               month="March";
               break;
           case 3:
               month="April";
               break;
           case 4:
               month="May";
               break;
           case 5:
               month="June";
               break;
           case 6:
               month="July";
               break;
           case 7:
               month="August";
               break;
           case 8:
               month="September";
               break;
           case 9:
               month="October";
               break;
           case 10:
               month="November";
               break;
           case 11:
               month="December";
               break;
       }
       cout << "Please enter the number of planes that landed in " << month << ": ";
       cin >> planes[pos].landed;
      
       cout << "Please enter the number of planes that departed in " << month << ":";
       //take input      
       cin >> planes[pos].departed;//add code here
      
       cout << "Please enter the greatest number of planes that landed on a single day in "
       << month << ": ";
       //take mostLanded input      
       cin >> planes[pos].mostLanded;//add code here
      
       cout << "Please enter the least number of planes that landed on a single day in "
       << month << ": ";
       //take least landed input      
       cin >>planes[pos].leastLanded ;//add code here
       //increment totalLandings and totalDeparted
       totalLandings =totalLandings+planes[pos].landed; //add code here
       totalDeparted = totalDeparted+planes[pos].departed;//add code here
       //update mostLandings      
       if (mostLandings < planes[pos].mostLanded)
       {
           mostLandings = planes[pos].mostLanded;//add code here
           monthMost = month;
       }
      
       if (leastLandings > planes[pos].leastLanded)
       {
           leastLandings = planes[pos].leastLanded;//add code here
           monthLeast = month;
       }
   }
  
  
   cout << setprecision(2) << fixed << showpoint;
  
   cout << "The average monthly landings for the year is "
   << (float)totalLandings/MAXMONTH << endl;
  
   cout << "The average monthly departures for the year is "
   << (float)totalDeparted/MAXMONTH << endl;
  
   cout << "The total landings for the year is " << totalLandings << endl;
   cout << "The total departures for the year is " << totalDeparted << endl;
  
   cout << "The greatest number of planes that landed in a single day is "
   << mostLandings << " which occured in the month of " << monthMost << endl;
  
   cout << "The least number of planes that landed in a single day is "
   << leastLandings << " which occured in the month of " << monthLeast << endl;
  
   return 0;
}


Related Solutions

Can someone please add clear and concise comments thoroughly explaining each line of code below. Just...
Can someone please add clear and concise comments thoroughly explaining each line of code below. Just need help understanding the code, don't need to modify it. The purpose of the code is to count the frequency of words in a text file, and return the most frequent word with its count. It uses two algorithms: Algorithm 1 is based on the data structure LinkedList. It maintains a list for word frequencies. The algorithm runs by scanning every token in the...
The Buyer’s Experience Before starting, please read these instructions thoroughly. Purpose: To recognize common sales strategies...
The Buyer’s Experience Before starting, please read these instructions thoroughly. Purpose: To recognize common sales strategies and their effect on the buyer; and analyzes the salesperson’s tactics using material from class. You will be provided with a list of what you are looking for during the interaction. Your Task: Select a product that you have genuine interest in purchasing sometime in the near future. Find a corporation*, big-box store, or a similar retailer in which you can visit to execute...
Please show solution and comments for this data structure using java.​ Implement a program in Java...
Please show solution and comments for this data structure using java.​ Implement a program in Java to convert an infix expression that includes (, ), +, -, *,     and / to postfix expression. For simplicity, your program will read from standard input (until the user enters the symbol “=”) an infix expression of single lower case and the operators +, -, /, *, and ( ), and output a postfix expression.
I need to complete this C++ program. The instructions are in the comments inside the code...
I need to complete this C++ program. The instructions are in the comments inside the code below: ------------------------------------------------------------------------- Original string is: this is a secret! Encypted string is: uijt!jt!b!tfdsfu" Decrypted string is: this is a secret! //Encoding program //Pre-_____? //other necessary stuff here int main() { //create a string to encrypt using a char array cout<< "Original string is: "<<string<<endl; encrypt(string); cout<< "Encrypted string is: "<<string<<endl; decrypt(string); cout<<"Decrypted string is: "<<string<<endl; return 0; } void encrypt(char e[]) { //Write implementation...
Please read the instructions and  find attached for the first wiki . Instructions for students: Read carefully...
Please read the instructions and  find attached for the first wiki . Instructions for students: Read carefully the attached document and then post your comments bearing in mind the following questions: 1- What are the pros and cons of rent controls? 2- Why economists disagree on the usefulness of rent control? 3- Do you believe rent control can help the poor? Edit Wiki Content rent control Rent regulation can take various forms, including rent control (the placing of a cap on...
Develop a python program to create a quiz with limited time and attempts!!! Add comments and...
Develop a python program to create a quiz with limited time and attempts!!! Add comments and screenshot of running the program quiz could be of anything like , what's the sum of 2&2. There should be number of attempts(limited) suppose if the answer is wrong.
Please add to this Python, Guess My Number Program. Add code to the program to make...
Please add to this Python, Guess My Number Program. Add code to the program to make it ask the user for his/her name and then greet that user by their name. Please add code comments throughout the rest of the program If possible or where you add in the code to make it ask the name and greet them before the program begins. import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the...
In Python3 please do the following: Program MUST take USER INPUT. The examples below are just...
In Python3 please do the following: Program MUST take USER INPUT. The examples below are just test cases for you to test the program. You are given a rare document that we suspect is written in an alien language. The alien language has the following grammar. All its words read the same backward as well as forward. E.g. aba. A sequence of these words are written as sentences. It is composed of only English alphanumeric([a-z, A-Z, 0-9]) characters in it....
Java Program Please Read all directions carefully Write a method named smallToLarge that asks the user...
Java Program Please Read all directions carefully Write a method named smallToLarge that asks the user to enter numbers, then prints the smallest and largest of all the numbers typed in by the user and the average (rounded to 2 decimal places). You may assume the user enters a valid integer number for the number of numbers to read. Here is an example dialogue: /* initialize smallest and largest variables with the 1st user input for Number */ How many...
Instructions Write a Java program that asks the user t enter five test scores. The program...
Instructions Write a Java program that asks the user t enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: * calcAverage -- This method should accept five test scores as arguments and return the average of the scores. * determineGrade -- This method should accept a test score as an argument and return a letter grade for the score, based on the following...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT