Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Simple Calculator Given the numbers N1, N2 and an operation character C. Write a simple calculator which performs the 4 basic mathematical operations (i.e. Addition,

Simple Calculator

Given the numbers N1, N2 and an operation character C.

Write a simple calculator which performs the 4 basic mathematical operations (i.e. Addition, subtraction. Multiplication, and division) according to given character C.

Hint: Use type-casting

Input:

5

10

+

Where:

  • First line of input represent number N1
  • Second line of input represents number N2]
  • Third line represents operation character C.

Output:

15.00

Note

  • if C is not a valid operation then display -1.00
  • If C is '/' (division) and N2 = 0 (zero) then display -2.00

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

Students also viewed these Programming questions