subject

Design and code a program including the following classes, as well as a client class to test all the methods coded: a passenger class, encapsulating a passenger. a passenger has two attributes: a name, and a class of service, which will be 1 or 2.a train class, encapsulating a train of passengers. a train of passengers has one attribute: a list of passengers, which must be represented with an arraylist. your constructor will build the list of passengers by reading data from a file called passengers. txt. you can assume that passengers. txt has the following format: instance, the file could contain: james 1ben 2suri 1sarah 1jane should include the following methods in your train class:
a method returning the percentage of passengers traveling in first class
a method taking two parameters representing the price of traveling in first and second class and returning the total revenue for the train
a method checking if a certain person is on the train; if he/she is, the method returns true; otherwise, it returns false

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 12:10
1. declare a constant named cents_per_pound and initialize with 25. 2. get the shipping weight from user input storing the weight into shipweightpounds. 3. using flat_fee_cents and cents_per_pound constants, assign shipcostcents with the cost of shipping a package weighing shipweightpounds.
Answers: 2
question
Computers and Technology, 22.06.2019 13:00
We as humans write math expression in infix notation, e.g. 5 + 2 (the operators are written in-between the operands). in a computer’s language, however, it is preferred to have the operators on the right side of the operands, i.e. 5 2 +. for more complex expressions that include parenthesis and multiple operators, a compiler has to convert the expression into postfix first and then evaluate the resulting postfix.write a program that takes an “infix” expression as input, uses stacks to convert it into postfix expression, and finally evaluates it. it must support the following operations: + - / * ^ % (example infix expression: (7 - 3) / (2 + 2)postfix expression: 7 3 - 2 2 + /result: 1guidelines: 1. you will need to use stacks in three placesa. one for the parenthesis check [char stack]b. one during infix to postfix [char stack]c. one during evaluation [int stack]for a and b above, you can use same array and same push, pop method as both ofthem are char. but for evaluation you have int stack and you might consider to createanother push pop method to handle it. maybe push_int, pop_int, etc. or find otherstrategy to utilize existing push pop method2. you can create a function for obtaining operator priority. that function should take anoperator as input and return its priority as an integer. this function will you a lot andreduce repeated code3. during evaluation you will need to convert char into integer. example for single digit: char c = '5'; int x = c - '0';
Answers: 2
question
Computers and Technology, 23.06.2019 00:20
Ihave been given the number of guns per 100, and the total firearm-related deaths per 100,000. i have to find the actual number of guns per country and actual number of gun-related deaths. if somebody could show me how to do 1 question, i can finish the rest, i am just confused. tia
Answers: 3
question
Computers and Technology, 23.06.2019 14:00
Select the correct answer. andre was recently hired by an organization to check for system vulnerabilities. he is supposed to exploit these vulnerabilities and create a report on the extent of damage to which the system was susceptible. what position does andre hold in this organization? a. information security analyst b. information assurance manager c. penetration tester d. network security engineer e. chief information security officer
Answers: 2
You know the right answer?
Design and code a program including the following classes, as well as a client class to test all the...
Questions
question
Biology, 26.09.2021 14:00
question
Computers and Technology, 26.09.2021 14:00
question
English, 26.09.2021 14:00
question
Mathematics, 26.09.2021 14:00
question
Mathematics, 26.09.2021 14:00
Questions on the website: 13722363