Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need answer in C# Concept Summary: 1. Object-Oriented programming concepts 2. Interfaces For this project you will develop a calculator that can do simple arithmetic

Need answer in C#

Concept Summary:

1. Object-Oriented programming concepts 2. Interfaces

For this project you will develop a calculator that can do simple arithmetic operations such as addition, subtraction, multiplication and division.

Youll begin by creating an interface CalcOp which has 4 methods: add(), subtract(), multiply() and divide().

Next youll create a Calculator class which implements the interface. This class should be concrete, as such all methods should be concrete.

Finally youll write a main method which instantiates a calculator, and presents the user with a menu. Prompt the user for 2 numbers and perform the appropriate operation based on their choice. Continue until the user chooses to exit.

Specifications:

The CalcOp interface should include the following items: Four methods: add( ), subtract( ), multiply( ) and divide( ) Each method should take in two floating point numbers and return a float.

The Calculator class should: Implement the methods defined in the interface.

Write a driver program which contains the following items:

A menu with options for exiting the program, addition, subtraction, multiplication and

division.

All Input / Output statements should be in the driver program only.

Test your program by running through all operations at least once.

Sample Output:

0 - Exit 1 - Addition 2 - Subtraction 3 - Multiplication 4 - Division

Please Choose an Option: 1 Please enter the first number 67 Please enter the second number 89 156.0

0 - Exit 1 - Addition 2 - Subtraction 3 - Multiplication 4 - Division Please Choose an Option: 2 Please enter the first number 90 Please enter the second number 89 1.0

0 - Exit 1 - Addition 2 - Subtraction 3 - Multiplication 4 - Division Please Choose an Option: 3 Please enter the first number 65 Please enter the second number 12 780.0

0 - Exit 1 - Addition 2 - Subtraction 3 - Multiplication 4 - Division Please Choose an Option: 4 Please enter the first number 18 Please enter the second number 2 9.0

0 - Exit 1 - Addition 2 - Subtraction 3 - Multiplication 4 - Division Please Choose an Option: 0

Submission Guidelines:

Write the interface, the class and the driver program for the project.

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

Step: 3

blur-text-image

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 A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions