(Solved) : Write C Program Perform Following 6 Operators 2 Numbers N1 N2 Need Prompt User Enter Numbe Q42696165 . . .

Write a C# program that can perform the following 6 operatorsfor 2 numbers: N1 and N2. You need

to prompt the user to enter a number, an operator, and anothernumber. To simplify your program, please

declare N1, N2, and result as double -floating numbers, andoperator as

char

. Please see the sample test

below to design your application program properly. This programis a

super calculator

for users to play.

Your program must continue asking for inputs from the user. Ifthe user enters ‘@’ as the operator, you must

thank the user and then exit the program immediately. As you cansee, PA 2 is to add some more user-

friendly features to Lab X – Simple Calculator.

The 6 valid operators for this

super calculator

are as follows:

1.

+

for addition of N1 and N2. Therefore, result = (N1 + N2).

2.

for subtraction of N2 from N1. Therefore, result = (N1 –N2).

3.

*

for multiplication of N1 with N2. Therefore, result = (N1 *N2).

4.

/

for floating-point division of N1 by N2.

If N2 is zero, you must continue asking the user to enter anon-zero value for N2 until a

non-zero value is received.

Then, result = (N1 / N2).

5.

^

for power N2 with base N1 (i.e., N1

N2

). Therefore, result =

Math.Pow

( N1 , N2 ).

6.

%

for integer-division remainder (i.e., modulus) of N1 by N2.

If N2 is zero, you must continue asking the user to enter anon-zero value for N2 until a

non-zero value is received.

Then, result = ( N1 % N2 ).

7. Otherwise, please say “Sorry, the operator ____ is notvalid”. // must show the invalid operator

8. @ for stopping the calculator game immediately.

– Program Design Considerations:

(1) use do { } while( );
(2) use switch statement instead of nested if else

Expert Answer


Answer to Write a C# program that can perform the following 6 operators for 2 numbers: N1 and N2. You need to prompt the user to e…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?