Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this homework, you will create a class that stores a list of transactions and computes the average transaction for a given month. The user

In this homework, you will create a class that stores a list of transactions and computes the average transaction for a given month. The user must input the name of the month and the transactions into the terminal. The Transaction_List Class First you will create two C++ files called abc1234_Transaction_List.h and abc1234_Transaction_List.cpp. Below is a UML class diagram that shows the basic design of the Transaction_List class. Transaction List -month : string transactions: vector-sdouble - num transactions: int +Transaction Listim string) + get_monthl): string + add transaction(transaction double] + average transaction]: int This class contains a list of transactions for a certain month. Each transaction is represented a double in the vector transactions. The constructor sets the month equal to the m and the num_transactions to 0. get_name returns the name of the month. add_transaction adds a new transaction to the list of transactions and 1 to num_transactions. average_transaction returns the average transaction for that month. If there are no transactions, then this should return 0. Testing the Transaction_List Next you will test your Transaction_List class by creating a new C++ file called abc1234_test.cpp, which consists of just a main method. The main function must be able to do the following three tests. Test #1 o Create a Transaction_List object named May and add 4 transactions: 150, 225.3, 78.9, and 523.99 o Get the Transaction_Lists name. If the month is not May, display a useful error message to the terminal (cout). o Compute the average transaction for the month. If the average is not 244.5475, display a useful error message to the terminal (cout). Test #2 o Create another Transaction_List called March and add 4 transactions: 150, 225.3, 78.9, and 523.99 o Get the Transaction_Lists name. If the month is not May, display a useful error message to the terminal (cout). o Compute the average transaction for the month. If the average is not 244.5475, display a useful error message to the terminal (cout). Test #3 o Create a Transaction_List object named May and add 4 transactions: 150, 225.8, 78.9, and 523.99 o Get the Transaction_Lists name. If the month is not May, display a useful error message to the terminal (cout). o Compute the average transaction for the month. If the average is not 244.5475, display a useful error message to the terminal (cout). The main program Third, write one more C++ file called abc1234_main.cpp. This main program consists of a main function that should do the following: (you may have to write more loops then what is listed below, or more functions then just main) Create a list (vector) of Transaction_Lists Prompt the user for the name of a month and take it in as input. Create a Transaction_List object with the name you just received as input. Create a loop that askes for a transaction and takes it in as input. o If the input is -999, exit the loop. o If the input is not -999, add it to the list of transactions. When the loop is terminated, add this month to the list of Transaction_Lists. Ask the user if there is another month he/she want to put in (Y/N) o If yes, go back to the second bullet point. o If no, print out the name of each Transaction_List (the month name) and the average, each on a different line..

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions

Question

5. Do you have any foreign language proficiency?

Answered: 1 week ago