Question

Thi s project will introduce switch-statements and logical operators Write a program that uses a switch-statement and loops t

please complete this program. and make sure it works. code only written in c++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
using namespace std;

int main() //main function
{
cout<<"1. Add Passenger\n2. Stop"<<endl;
int option;
int flightclass;
int destination;
int count = 0; //count of passengers
cout<<"Select the option: (1 to add passenger, 0 to stop) "<<endl;
cin>>option;
while(option == 1)
{
cout<<"Enter the class and destination(1 for Miami, 2 for Los Angeles): "<<endl;
cin>>flightclass>>destination; //input
switch(flightclass){ //switch for class
case 3:
case 4:
case 5:
if(destination == 1){
cout<<"Flight#1 Headed to Miami"<<endl;
cout<<"Class: "<<flightclass<<endl;
count++;
} else if(destination ==2){
cout<<"Flight#2 Headed to Los Angeles"<<endl;
cout<<"Class: "<<flightclass<<endl;
count++;
} else {
cout<<"Wrong destination choice"<<endl;
}
break;
default:
cout<<"No seating available for requested class"<<endl;
}
cout<<"Select the option: (1 to add passenger, 0 to stop) "<<endl;
cin>>option;
}

cout<<"Total passengers: "<<count;

return 0;

}

1. Add Passenger 2. Stop Select the option: (1 to add passenger, e to stop) Enter the class and destination(1 for Miami, 2 fo

Add a comment
Know the answer?
Add Answer to:
please complete this program. and make sure it works. code only written in c++ Thi s...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solu...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solutions. Instructions 1. Read instructions carefully! 2. Use C++ syntax only, C syntax will not be accepted. 3. Always use braces to define blocks. 4. Indent all lines within a block. Each block requires one more tab. 5. Organize your code well with proper formatting and a single...

  • C++ ONLY Please TRAINS DESCRIPTION You are completing a program that allows for several different types...

    C++ ONLY Please TRAINS DESCRIPTION You are completing a program that allows for several different types of passenger trains. One train can hold only cats. Another train can hold only wizards. You are going to create a Wizard class, a Cat class, and a Train class. You are provided the driver, lab2.cpp. The Train class should be a template class where the type of passenger is the template data type. Specifications cat class Attributes: name of cat breed of cat...

  • I have to write a C program to assign seats on each flight of the airline’s...

    I have to write a C program to assign seats on each flight of the airline’s only plane (capacity: 40 seats, in 10 rows). For the sake of simplicity, assume that each row has 4 seats labeled A, B, C, D. Your program should display the following menu of alternatives: Please type 1 for "first class" Please type 2 for "business class" Please type 3 for “economy class”. If the person types 1, then your program should assign a seat...

  • C++ : Please include complete source code in answer This program will have names and addresses...

    C++ : Please include complete source code in answer This program will have names and addresses saved in a linked list. In addition, a birthday and anniversary date will be saved with each record. When the program is run, it will search for a birthday or an anniversary using the current date to compare with the saved date. It will then generate the appropriate card message. Because this will be an interactive system, your program should begin by displaying a...

  • code in java please:) Part I Various public transporation can be described as follows: A PublicTransportation...

    code in java please:) Part I Various public transporation can be described as follows: A PublicTransportation class with the following: ticket price (double type) and mumber of stops (int type). A CityBus is a PublicTransportation that in addition has the following: an route number (long type), an begin operation year (int type), a line name (String type), and driver(smame (String type) -A Tram is a CityBus that in addition has the following: maximum speed (int type), which indicates the maximum...

  • C++ Programming Assignment S Mammal Lab This lab's goal is to give you some practice using inheritance, virtual functions, pointers, dynamic memory allocation, random numbers, and polym...

    C++ Programming Assignment S Mammal Lab This lab's goal is to give you some practice using inheritance, virtual functions, pointers, dynamic memory allocation, random numbers, and polymorphism. To complete the lab implement the following steps: Create a class called Mammal. All mammals have a weight and a name, so its data should be the mammal's weight and name. Provide a default constructor that sets the mammal's weight to 0 and name to null, and another constructor that allows the weight...

  • What happened on United flight 3411?What service expectations do customers have of airlines such ...

    What happened on United flight 3411?What service expectations do customers have of airlines such as United and How did these expectations develop over time? Thank You! In early April 2017, United Airlines (United), one of the largest airlines in the world, found itself yet again in the middle of a service disaster this time for forcibly dragging a passenger off an overbooked flight. The incident was to become a wake-up call for United, forcing it to ask itself what to...

  • Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What...

    Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What This Assignment Is About? Classes (methods and attributes) • Objects Arrays of Primitive Values Arrays of Objects Recursion for and if Statements Selection Sort    Use the following Guidelines: Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc.) Use upper case for constants. • Use title case (first letter is upper case) for classes. Use lower case with uppercase...

  • Can you please help me with creating this Java Code using the following pseudocode? Make Change C...

    Can you please help me with creating this Java Code using the following pseudocode? Make Change Calculator (100 points + 5 ex.cr.)                                                                                                                                  2019 In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you...

  • I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instruction...

    I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instructions Here is the code Produce correct70 pts O pts Full Marks No Marks results and statisfy requirements view longer Comments 1. Your display amount is not readable 2. I withdraw more than my balance, but I didn't see any error message description Documentations10 pts 0 pts Full Marks No Marks : comment i code and block comment...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT