Question: C++Programming Write a function named frequent flier that accepts an input stream and an output stream as parameters. The input stream represents an input file
C++Programming

Write a function named frequent flier that accepts an input stream and an output stream as parameters. The input stream represents an input file which represents all of the flights a person has taken. Your function should compute and return an integer representing the total frequent flyer miles the person has earned. The input consists of pairs of tokens where each pair begins with the type of ticket that the person bought coach", "firstclass, or "discount, case-sensitively and is followed by the number of miles of the flightThe rules for awarding frequent flier miles are: . 1 frequent flyer mile is earned for each mile traveled in coach. . 2 frequent flyer miles are earned for each mile traveled in first class. Zero frequent flyer miles are earned on a discounted flight For example, if an input stream named input refers to a file containing the following text: coach 15ee firstclass 2880 discount 900 coach 350 In this example, the person earns 1500 frequent flyer miles for the first flight, 4000 frequent flyer miles for the second flight, o frequent flyer miles for the third flight, and 3500 frequent flyer miles for the fourth flight. Therefore the call of frequentFlier(input, cout) should return 9000 (a total of 1500 + 2-2000 + 3500). The input might span multiple lines and might have different spacing between tokensYou are to process all tokens on all lines together. For example, if an input stream named input2 refers to an input file containing the following text: 5000 coach 158e coach firstclass 100 firstclass 20ee discount 300 Then the call of frequentFlier(input2, cout) should return 15600 (a total of 25000 + 1500 + 100 + 22000). You may assume that the input file exists and follows the format above that the file has an even number of tokens and contains at least 1 pair of tokens that every other token is an integerand that the other tokens are valid ticket types
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
