Program that can serve as a simple calculator

Assignment Help C/C++ Programming
Reference no: EM13165391

Write a program that can serve as a simple calculator. This calculator keeps track of a single number (of type double) that is called result and that starts out as 0.0. Each cycle allows the user to repeatedly add, subtract, multiply, or divide by a second number. The result of one of these operations becomes the new value of result. The calculation ends when the user enters the letter R for "result" (either in uppercase or lowercase). The user is allowed to do another calculation from the beginning as often as he or she wants. Use the scanf for input.

The input format is shown in the following sample dialog. If the user enters any operator symbol other than +, ?, *, or /, then display message "UnknownOperatorException is thrown " and the user is asked to reenter that line of input..

Calculator is on.
result = 0.0
+5
result + 5.0 = 5.0
result = 5.0
*2.2
result * 2.2 = 11.0
result = 11.0
% 10
% is an unknown operation
Reenter, your last line:
* 0.1
result * 0.1 = 1.1
result = 1.1
r
Final result = 1.1
Again? (y/n)
yes
result = 0.0
+10
result + 10.0 =10.0
result = 10.0   
/2
result / 2.0 = 5.0
updated result = 5.0
r
Final res

Reference no: EM13165391

Questions Cloud

Evaluate and use quantitative and qualitative information : Evaluate and use quantitative and qualitative information to measure financial and non financial performance of an organisation
Integer arguments representing feet : A constructor that will take a single integer argument representing a whole number of feet • A constructor that will take two integer arguments representing feet and inches respectively • A constructor that will take three integer arguments represent..
Program to generate a star-based histogram for a quiz : Write a C++ program to generate a star-based histogram for a quiz (maximum score possible is 5) given to a class of N students, where N is an input from the user. Use arrays for computation.
State newton''s third law of motion : Newton's third law of motion can be stated like this: "For every action, there is an equal and opposite reaction." How are Le Chatelier's Principle and Newton's third law similar? How are they different?
Program that can serve as a simple calculator : Write a program that can serve as a simple calculator. This calculator keeps track of a single number (of type double) that is called result and that starts out as 0.0. Each cycle allows the user to repeatedly add, subtract, multiply, or divide by..
Determine the center temperature of the product : Determine the center temperature of the product afer 60 minutes if the convective heat transfer coefficient between the product and mbient air is 25 W/m^2 K.
How do a bubble sort in mips? : How do a bubble sort in MIPS?
Commercial tablet was determined by titration : The amount of aspiring (molar mass of 180.15 g/mole) in a commercial tabletwas determined by titration with NaOH. What mass of aspiring was in a tablet if 15.00 mL
Store a list of student info : Store a list of student info, (id number, First name and Last name) using a link list. The ID is the key field. The program should implement a linked list using arrays.The program should process the following operations

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write two short c programs and solve exam-style problem

Write two short C programs and solve four exam-style problems.

  Design and write a c++11/fltk game program

The project is to design and write a C++11/FLTK game program with a graphical user interface. The game is based on "pancake sorting," which actually has some mathematical significance.

  Write a c function void print_triangle(int n)

Write a C function void print_triangle(int n) that prints a triangular pattern of asterisks of height n and width 2 * n + 1 with one asterisk in the first line, three in the second line, etc.,

  Each clone will communicate to the parent process

Write a program that will create 3 clones. Each clone will communicate to the parent process over a pipe (There are 3 pipes) Each process will write Process n.

  C program to solve the quadratic equation of rocket launch

Write a C program to solve the quadratic equation of rocket launch by computing the roots (t1 and t2) of that quadratic equation: gt2 + vt + l = 0 (or) for simplicity ax2 + bx + c = 0. Get the values of g, v, and l from the user. The program should d..

  Use a for loop to generate 100 random numbers.

Use a For Loop to generate 100 random numbers. Determine the most current maximum and minimum number as the random numbers are being generated. This is referred tp as a "running" maximum and minimum. Display the running maximum and minimum values as ..

  Extend the definition of the class clocktype by overloading

a. Extend the definition of the class clockType by overloading the post-increment operator function as a member of the class clockType

  C assignment of curl library

C Assignment Curl library must be used To be done on linux, it should be compiled using the following command: gcc -Wall -ansi -pedantic NameOfFile.c -lncurses Please make sure it is commented with clarification Variable names in camel case

  Write a program to find out all 3-digit

Write a program to find out all 3-digit Narcissistic number. A number n is a 3-digit Narcissistic number if: (a) 100   n   999, (b) The sum of its own digits each raised to the power of 3 equals to itself. For example: 153 is a Narcissistic number ..

  State diagram to recognize one form

Design a state diagram to recognize one form of the comments of the C-based programming languages, those that begin with /* and end with */. and also Write and test the code to implement the state diagram.

  Skills required by personnel working in information security

What skills are required by personnel working in information security? Write down some job titles in the field and come up with some required qualifications and some desirable qualifications.

  Struct definition to represent the data of a person''s bank

Define a struct definition to represent the data of a person's bank account. There will be one string for the name, and two doubles for balance and interest rate. Declare two variables of this new type in the main function. Modify the values of each ..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd