1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Licemer1 [7]
3 years ago
8

Write a program that defines an interface having the following methods: addition, subtraction, multiplication, and division. Cre

ate a class that implements this interface and provides appropriate functionality to carry out the required operations. Hard code two operands in a test class having a main method that calls the implementing class.
Computers and Technology
1 answer:
Tatiana [17]3 years ago
7 0

Hello, you haven't provided the programing language in which you need the code, I'll explain how to do it using Python, and you can follow the same logic to make a program in the programing language that you need.

Answer:

1. # -*- coding: utf-8 -*-

2. #Python  

3. class Calculator:

4.     def add(self):

5.         print(a + b)

6.     def sub(self):

7.         print(a - b)

8.     def mul(self):

9.         print(a * b)

10.     def div(self):

11.         print(a / b)

12.  

13. obj = Calculator()

14. choice = 1

15. while choice != 0:

16.     a = int(input("\nEnter first number: "))

17.     b = int(input("Enter first number: "))

18.      

19.     print("\n0. EXIT")

20.     print("1. DIVISION")

21.     print("2. ADDITION")

22.     print("3. SUBTRACTION")

23.     print("4. MULTIPLICATION")

24.      

25.     choice = int(input("\nEnter your choice: "))

26.     if choice == 1:

27.         obj.div()

28.     elif choice == 2:

29.         obj.add()

30.     elif choice == 3:

31.         obj.sub()

32.     elif choice == 4:

33.         obj.mul()

34.     else:

35.         break

Explanation:

  • From lines 1 to 12 we define the object with four methods, addition, subtraction, multiplication, and division. Each method contains the operation between two variables inside a print function
  • On line 13 we instantiate our class
  • On line 14 we declare the variable choice that is going to store the operation that the user wants to perform
  • On line 15 we declare a while loop, this is going to keep running the program until the user wants to exit
  • From line 16 to 18 we ask the user to enter two numbers
  • From line 19 to 24 we print the possible operation, assigning a number for each operation, this indicates to the user what number to press for what operation
  • On line 25 we ask the user for the operation
  • From lines 26 to 35 we check the user input an accordingly we call the corresponding method to performs the operation
You might be interested in
Donna is in the Outlook Today window and clicks the F1 button on her keyboard. What is Donna most likely trying to do?
Jobisdone [24]
I believe the answer is D. <span>use the Help feature of Outlook
In general, f1 is the shortcut to access help feature in almost all computer program.
Other than using this method, Donna could also use 'tell me what to do' phrase in the query box in order to access the feature.</span>
8 0
3 years ago
Read 2 more answers
You should check your battery ___________. Every week Never Every six months Every 30,00 miles
vova2212 [387]

The answer is Every six months

A battery acts as the brain of a car and is used to power almost everything. It can last up to five years. However, this lifespan will depend on how well the battery is maintained and the type of weather conditions you live in. Aim to check your car battery at least twice a year. Actually, it is best to check your battery regularly and not to wait for your mechanic to test your battery during routine servicing.

5 0
4 years ago
Read 2 more answers
You are trying to appreciate how important the principle of locality is in justifying the use of a cache memory, so you experime
murzikaleks [220]

Answer:

Explanation:

Attached is the solution

3 0
3 years ago
What are the correct steps to add the bill using the receipt capture feature in quick books online?
Gennadij [26K]

Answer:

How it Works

The Bill can be imported into QuickBooks in a verity of methods such as drag and drop, browse to upload, email and image upload from a mobile device. The imported data is processed by QuickBooks. In my testing this processing varied depending on the type of document sent but overall, the process was fast, and the Bill was ready to view and categorized within five minutes. There were several pieces of data already extracted from the document which were the data and dollar amount but all other details in my experience needed to be entered.

One thing to not is you can not expense by line items at this time. Instead you can only choose one expenses account per transaction. (if I were a betting girl, I would say this is in the works, but I have no official word on that) However, you can add Classes and Billable Customers.

How to Get Started:

1) From the QBO Navigation Bar choose Banking Center

2) Select the Receipts tab

3) Drag and drop, email or upload a mobile image of the document to QuickBooks (1 file at a time)

4) From the For Review section of the Receipts tab you can see when the document is ready for review

5) QuickBooks extracts, data including date and dollar amount

6) Click on Review in the Action column

7) Select Bill as Document Type (as shown highlighted in the 'red box')

8) Enter the remaining details:

- Enter Payee

- Approve Bill date and enter due date

- Select Account  

- Verify amount total

- Additional Fields (optional)

- Make expenses billable

- Select Customer

- Class

- Add reference number

9) Import into QuickBooks by Saving and Closing

Within, seconds your document is coded and published into QuickBooks as an Open Bill pending payment. Like I said for now all you can add is an account but if you published the document to QBO you could later open it and edit to add required items if necessary.

The last step in optimization is after you have posted the payment to the open bill you will be able to match the bank feeds in QBO if you have already imported your banking activity. This type of audit proofing your bookkeeping helps prevent fraud and assures accuracy.

Hope this helps!! Merry Christmas!! And Happy New Year!!

6 0
3 years ago
Need Help ASAP! You might create a flowchart as part of the ___
zepelin [54]

Answer:

design .

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • On the home ribbon, what do you use to change the font size of characters in a cell
    9·1 answer
  • What is the difference between 1080p and 2k?
    14·1 answer
  • To get revenge on the pizza parlor burning his pizza and not reimbursing him for it, David returned to the pizza parlor after-ho
    9·2 answers
  • Please help me ! All you do is just put it it all in your own words ! Please this is for my reported card!i don't know how to pu
    15·1 answer
  • Which of the following is a great collection of resources for those entering the workplace or embarking on a new career?
    12·2 answers
  • Tina has made a database table in access containing field name class roll number and contact number she has set primary key for
    5·1 answer
  • Default tab stops are set in word every _______ inch. a. ¾ b. ½ c. 1 d. ¼
    7·1 answer
  • If you have a database of books in the library and you would like to find all books published after January 1, 2008, what criter
    7·1 answer
  • ⦁ ¿Cuáles son los recursos naturales que se utilizan en tu comunidad para generar energía eléctrica?
    14·1 answer
  • I umm… really need helpp<br> Can someone help me out <br> I’ll even mark u as brainiest !
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!