Home / Expert Answers / Computer Science / a-create-a-class-named-account-that-has-the-following-variables-custname-accnum-acctype-am-pa993

(Solved): a) Create a class named Account that has the following variables: custname, accnum, acctype, am ...



a) Create a class named Account that has the following variables:
custname, accnum, acctype, amt
b) Create a constructor for

a) Create a class named Account that has the following variables: custname, accnum, acctype, amt b) Create a constructor for the variables above. ( 4 marks) c) Write setters and getters for the custname and amt. (4 marks (12 marks d) Write a statement to instantiate an object named acc1 that has the following data: Logan Long Ngan, 235745378-0-1234, Basic Savings, RM 10,000.50 mark


We have an Answer from Expert

View Expert Answer

Expert Answer



SOLUTION:-
a) Create a class named Account that has the following variables: custname, accnum, acctype, amt
STEP 1:-
Here's an example of a Python class named Account with the variables custname, accnum, acctype, and amt:



In this class, the __init__ method is used as the constructor to initialize the instance variables custname, accnum, acctype, and amt. The constructor takes these variables as parameters and assigns them to the corresponding instance variables using the self keyword.

You can create an instance of the Account class by calling the constructor and passing the required values. Here's an example:


In this example, account1 is an instance of the Account class, and you can access its instance variables using the dot notation (account1.custname, account1.accnum, etc.).
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe