SEP200 XXXXXXXXXXSummer 2022 Term Object-Oriented Programming Final Test-Question-Part2 Page 1 of 4 Instructions: • The Final Test-Part2 should be completed individually. • Part2 is worth 50% of the...

1 answer below »
Everything is included in 123.pdf


SEP200 Summer 2022 Term Object-Oriented Programming Final Test-Question-Part2 Page 1 of 4 Instructions: • The Final Test-Part2 should be completed individually. • Part2 is worth 50% of the final test grade and will be evaluated through your submission. • Duration: You have 75 minutes to complete this part. • Every file that you submit must contain (as a comment) at the top your name, your Seneca email, Seneca Student ID and the date when you completed the work. • Add comments throughout the code where necessary. • The submitted files must be appropriately created according to C++ standards and best practices. • Submit the required file(s) through Blackboard. • If you have to submit more than one file, you must merge the required files into one zip file and upload it through Blackboard. Question 1. Complete the following program by coding a class called Wallet and a global function called AddTax. a. You need to download the startup code file: main.cpp Note the startup code is not complete and contains compilation errors. Your task is to complete the program by coding a class called Wallet and a global function called AddTax. AddTax Function Requirements • Your global function named AddTax receives as input parameters iterators to the beginning and end of a range of lottery Tickets. • This function adds HST to the price data member for each Ticket in the received range and stores the result in the price_w_tax data member. SEP200 Summer 2022 Term Object-Oriented Programming Final Test-Question-Part2 Page 2 of 4 Wallet Class Requirements Your Wallet class includes the following members: • An STL container that holds lottery Ticket objects • A boolean flag that holds true only if all Ticket objects in the container have their HST added • An overloaded += operator that adds a Ticket object to the container, sets the boolean flag to false and returns a reference to the current object only if the ratio of the prize to the price (prize/price) for that Ticket object is greater than or equal to the good-odds ratio ((prize/price) >= GOOD_ODDS). o If the ratio is less than the GOOD_ODDS ratio , then this operator changes nothing and throws an exception of type string with the message as shown in the sample output below.  Remember to update main to handle the exception. • A member function named display that: o receives the address of one of the global functions that display the requested information (byName or byOdds) and calls it for each Ticket object. If the received address is invalid, this function terminates the program with code 11. o adds HST to the price for each Ticket object (if necessary; see next bullet) and displays the requested data. o If any data (i.e., Ticket) in the container is not taxed, this function adds tax using the AddTax function and two threads before printing anything. For this purpose, the function divides the container elements into two consecutive halves where each thread processes one half. Other Mandatory Requirements • Upgrade the main function of the program to use a smart pointer. SEP200 Summer 2022 Term Object-Oriented Programming Final Test-Question-Part2 Page 3 of 4 Startup Code Exists in the file main.cpp You need to download the startup code file: main.cpp Note the startup code is not complete and contains compilation errors. Your task is to complete the program by coding a class called Wallet and a global function called AddTax. #include #include #include constexpr double HST{ 0.13 }; constexpr double GOOD_ODDS{ 20.0 }; // odds cutoff struct Ticket { std::string name; unsigned prize; double price; double price_w_tax; }; void byName(const std::vector& lotteries) { std::cout < std::fixed="">< std::setprecision(2);="" std::cout="">< "\nlottery="" price\n";="" for="" (auto&="" l="" :="" lotteries)="" std::cout="">< std::setw(10)="">< std::left="">< l.name="">< ":="" "="">< std::setw(5)="">< std::right="">< l.price_w_tax="">< '\n';="" }="" void="" byodds(const="">& lotteries) { std::cout < std::fixed="">< std::setprecision(2);="" std::cout="">< "\nprize/price="" price\n";="" for="" (auto&="" l="" :="" lotteries)="" std::cout="">< std::setw(11)="">< std::left="">< l.prize="" l.price_w_tax="">< ":="" "="">< std::setw(5)="">< std::right="">< l.price_w_tax="">< '\n';="" }="" int="" main()="" {="" ticket="" winner[]{="" {"lotto="" max="" ",="" 350,="" 5.00},="" {"lotto="" 6/49",="" 140,="" 3.00},="" {"daily="" keno",="" 25,="" 0.99},="" {"encore="" ",="" 10,="" 1.00},="" {"ontario="" 49",="" 20,="" 1.00},="" };="" wallet*="" wallet="new" wallet();="" for="" (const="" auto&="" i="" :="" winner)="" *wallet="" +="i;" wallet-="">display(byName); wallet->display(byOdds); delete wallet; } SEP200 Summer 2022 Term Object-Oriented Programming Final Test-Question-Part2 Page 4 of 4 Sample Output The output produced by this program using your solution should be: Poor Odds on Encore Prize/Price Price 61.95 : 5.65 41.30 : 3.39 22.35 : 1.12 17.70 : 1.13 Lottery Price Lotto Max : 5.65 Lotto 6/49: 3.39 Daily Keno: 1.12 Ontario 49: 1.13 How to Submit your Solution • You must submit one file: main.cpp • If you have to submit more than one file, you must merge the required files into one zip file and upload it through Blackboard. Instructions: AddTax Function Requirements Wallet Class Requirements Other Mandatory Requirements Startup Code Exists in the file main.cpp Sample Output How to Submit your Solution
Answered Same DayAug 17, 2022

Answer To: SEP200 XXXXXXXXXXSummer 2022 Term Object-Oriented Programming Final Test-Question-Part2 Page 1 of 4...

Jahir Abbas answered on Aug 17 2022
73 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here