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 first program is to count the number of zeros in $3855. Please     add comments...
The first program is to count the number of zeros in $3855. Please     add comments to each line                 org   $1000 array     db $38, $55 ; data to be tested                      org $1100 zero_cnt ds.b   1 lp_cnt     ds.b   1              org   $1500              clr   zero_cnt       ;initialize the 0 count to 0              movb #16,lp_cnt                   ldd   array         again     lsrd             bcs   chk_end         ;             inc   zero_cnt chk_end   dec   lp_cnt                           bne   again                               swi                          end
USING THE FOLLOWING DATABASE: [Please read the instructions thoroughly, this is my 6th time posting this...
USING THE FOLLOWING DATABASE: [Please read the instructions thoroughly, this is my 6th time posting this same question.] ========= -- SQL Script for Generating Kitchen Database drop database if exists kitchen; create database kitchen; use kitchen; drop table if exists recipe; drop table if exists food; create table food (fid int, fname varchar(45) not null unique, primary key(fid)); drop table if exists ingredient; create table ingredient (iid int, iname varchar(45) not null unique, caloriepergram float, category varchar(20), primary key(iid) );...
Python3  Please add comments Write a program that implements the word guessing game - There is a...
Python3  Please add comments Write a program that implements the word guessing game - There is a secret word - The user enters letters one at a time, if the letter appears in the secret word, it is revealed. Otherwise, it counts as a wrong guess. If the user reveals all the letters in the word before getting too many wrong guesses then they win! Otherwise, they lose. 1 - define secret word 2 - create a revealed letter list that...
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.
C++ please Instructions Download and modify the Lab5.cpp program. Currently the program will read the contents...
C++ please Instructions Download and modify the Lab5.cpp program. Currently the program will read the contents of a file and display each line in the file to the screen. It will also display the line number followed by a colon. You will need to change the program so that it only display 24 lines from the file and waits for the user to press the enter key to continue. Do not use the system(“pause”) statement. Download Source Lab 5 File:...
Please complete the following code in C using the comments as instructions. Further instructions are below...
Please complete the following code in C using the comments as instructions. Further instructions are below the code. challenge.c // goal: print the environment variables to the file "env.txt", one per line // (If envp is NULL, the file should be empty, opening in write mode will do that.) // example: // inputs: // envp/environ = {"E1=2","E2=7",NULL} // outputs: // env.txt as a string would be "E1=2\nE2=7\n" // example: // inputs: // envp/environ = {NULL} or NULL // outputs: //...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT