Question

In this homework, you will create a class that stores a list of transactions and computes...

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_List’s 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_List’s 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_List’s 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..

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream.h>
#include <iomanip.h>
#include <conio.h>

class    bank
{
char name[20];
int acno;
char actype[20];
int bal;
public :
void opbal(void);
void deposit(void);
void withdraw(void);
void display(void);
};

void bank :: opbal(void)
{
cout<<endl<<endl;
cout<<"Enter Name :-";
cin>>name;
cout<<"Enter A/c no. :-";
cin>>acno;
cout<<"Enter A/c Type :-";
cin>>actype;
cout<<"Enter Opening Balance:-";
cin>>bal;
}

void bank :: deposit(void)
{
cout<<"Enter Deposit amount :-";
int deposit=0;
cin>>deposit;
deposit=deposit+bal;
cout<<"\nDeposit Balance = "<<deposit;
bal=deposit;
}

void bank :: withdraw(void)
{
int withdraw;
cout<<"\nBalance Amount = "<<bal;
cout<<"\nEnter Withdraw Amount :-";
cin>>withdraw;
bal=bal-withdraw;
cout<<"After Withdraw Balance is "<<bal;
}

void  bank :: display(void)
{
cout<<endl<<endl<<endl;
cout<<setw(50)<<"DETAILS"<<endl;
cout<<setw(50)<<"name      "<<name<<endl;
cout<<setw(50)<<"A/c. No.     "<<acno<<endl;
cout<<setw(50)<<"A/c Type      "<<actype<<endl;
cout<<setw(50)<<"Balance     "<<bal<<endl;
}

void main()
{
clrscr();
bank o1;
int choice;
    do
    {
           cout<<"\n\nChoice List\n\n";
           cout<<"1)  To assign Initial Value\n";
         cout<<"2)  To Deposit\n";
         cout<<"3)  To Withdraw\n";
         cout<<"4)  To Display All Details\n";
         cout<<"5)  EXIT\n";
         cout<<"Enter your choice :-";
         cin>>choice;
         switch(choice)
         {
         case 1: o1.opbal();
                     break;
         case 2: o1.deposit();
                     break;
           case 3: o1.withdraw();
                     break;
         case 4: o1.display();
                     break;
            case 5: goto end;
         }
   }while(1);
end:
} 
Add a comment
Know the answer?
Add Answer to:
In this homework, you will create a class that stores a list of transactions and computes...
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
  • create java application with the following specifications: -create an employee class with the following attibutes: name...

    create java application with the following specifications: -create an employee class with the following attibutes: name and salary -add constuctor with arguments to initialize the attributes to valid values -write corresponding get and set methods for the attributes -add a method in Employee called verify() that returns true/false and validates that the salary falls in range1,000.00-99,999.99 Add a test application class to allow the user to enter employee information and display output: -using input(either scanner or jOption), allow user to...

  • Programming: Create a class called City with two public variables: a string to store the name...

    Programming: Create a class called City with two public variables: a string to store the name of the city and a float to store the average temperature in Fahrenheit. Create one object of the class that you create and ask the user to enter the city name and the average temperature in Fahrenheit. Store these in the object of the class that you create. Then display the contents of the class. Once that is working, make the variables private and...

  • In C++ Write a program that contains a class called VideoGame. The class should contain the...

    In C++ Write a program that contains a class called VideoGame. The class should contain the member variables: Name price rating Specifications: Dynamically allocate all member variables. Write get/set methods for all member variables. Write a constructor that takes three parameters and initializes the member variables. Write a destructor. Add code to the destructor. In addition to any other code you may put in the destructor you should also add a cout statement that will print the message “Destructor Called”....

  • import java.util.*; /** Description: This program determines the average of a list of (nonnegative) exam scores....

    import java.util.*; /** Description: This program determines the average of a list of (nonnegative) exam scores. Repeats for more exams until the user says to stop. Input: Numbers, sum, answer Output: Displays program description Displays instruction for user Displays average Algorithm: 1. START 2. Declare variables sum, numberOf Students, nextNumber, answer 3. Display welcome message and program description 4. DOWHILE user wants to continue 5. Display instructions on how to use the program 6. Inititalize sum and number of student...

  • Visual C# Homework 2 You are to write a program which will create a class called...

    Visual C# Homework 2 You are to write a program which will create a class called Student Each student has a name age height and weight. These variables should be declared as private. Create the correct constructors and functions. In the main, you will create 5 students. Input the data for the 5 students from a file which already has information in it. Name the file “Information.txt”. After setting up all the data, it is time to sort based on...

  • You may not add any instance variables to any class, though you may create local variables...

    You may not add any instance variables to any class, though you may create local variables inside of a method to accomplish its task. No other methods should be created other than the ones listed here.    Step 1 Develop the following class: Class Name: CollegeDegree Access Modifier: public Instance variables Name: major Access modifier: private Data type: String Name: numberOfCourses Access modifier: private Data type: int Name: courseNameArray Access modifier: private Data type: String [ ] Name: courseCreditArray Access...

  • You may not add any instance variables to any class, though you may create local variables...

    You may not add any instance variables to any class, though you may create local variables inside of a method to accomplish its task. No other methods should be created other than the ones listed here. (I need step 2 please.) Step 1 Develop the following class: Class Name: CollegeDegree Access Modifier: public Instance variables Name: major Access modifier: private Data type: String Name: numberOfCourses Access modifier: private Data type: int Name: courseNameArray Access modifier: private Data type: String [...

  • Implement the following classes in the UML: 1. List class includes:       constructor List(): Create an...

    Implement the following classes in the UML: 1. List class includes:       constructor List(): Create an empty list with a length of 100. Hint: double [] list = new double [100];       constructor List(len: int): Create a List with a user specified maximum length. Hint: double [] list = new double [len];       add: add a new element to the end of the unsorted list.       print: display the list 2.SortedList class includes       two constructors : similar to the...

  • Create an Inventory class with data members for stock number, quantity, and price, and overloaded data...

    Create an Inventory class with data members for stock number, quantity, and price, and overloaded data entry and output operators. The data entry operator function should throw: - An error message, if the stock number is negative or higher than 999 - The quantity, if it is less than 0 - The price, if it is over $100.00 Then perform the following tasks: a. Write a main() function that instantiates an array of five Inventory objects, and accepts data for...

  • In this assignment you are asked to write a python program to maintain the Student enrollment...

    In this assignment you are asked to write a python program to maintain the Student enrollment in to a class and points scored by him in a class. You need to do it by using a List of Tuples What you need to do? 1. You need to repeatedly display this menu to the user 1. Enroll into Class 2. Drop from Class 3. Calculate average of grades for a course 4. View all Students 5. Exit 2. Ask the...

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