Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Topics: class, object, instantiation, methodsProblem Statement: In this lab, you will design a very simple calculator application with the basic functionalities. The purpose of this

Topics: class, object, instantiation, methodsProblem Statement:In this lab, you will design a very simple calculator application with the basic functionalities. The purpose of this assignmentis to gain experiencein basic OOP concepts. Problem Scenario:You would ask two user input a and busing your favorite input function. Then the program should display a menu that is similar to a calculator application.Theoperations that need to be implemented are 1)addition, 2) multiplication, 3) subtraction, 4) divisionand5) powerfunction. You can choose to implement your own power function or you can use the built-in functions in the standard module. The menu should havean exit option to exit the program and user can choose to stay in the application until s/he decides to leave theapplication. Proper documentation for each of the methods and exception handling are required. For example: your program should be able to handle zero division operationor any non-numeric numberlike string values.

Design your solution:Class Definition: You need todesigna class named Calculator. To design your class,you can take the following approach:Write down a description of your problem (what should the problem do?). Underline all the nouns, verbs, and adjectives. For example:A Calculatorapplicationwhich is able to add, subtract, divide, multiply and perform exponential(user choice)ontwo user numbers. 1.Go through the nouns, these arepotential classes: Calculator2.Go through the verbs, they arepotential methods: add, subtract etc.You also need to define __init__ and __str__ methodand any other additionalmethod you need. 3.Go through the inputsand output, looking for potential attributes: user inputs, kind of operationand result4.Allocate methods and attributes to your classesMenu and Object Creation:You can write a simplemain function to create your menu and object.A sample object creation can be as: c = Calculator(x, y, +)wherex,y = user numbers and +is the operation to be performed.

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

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions