Calculator that prompts the user for two numbers

Assignment Help Computer Engineering
Reference no: EM132217412

Writing functions that return a value

In this lab, you complete a partially written C++ program that includes a function that returns a value.

The program is a simple calculator that prompts the user for two numbers and an operator ( +, -, *, or / ).

The two numbers and the operator are passed to the function where the appropriate arithmetic operation is performed.

The result is then returned to the main() function where the arithmetic operation and result are displayed. For example, if the user enters 3, 4, and *, the following is displayed: 3 * 4 = 12

The source code file provided for this lab includes the necessary variable declarations and input and output statements. Comments are included in the file to help you write the remainder of the program.

Instructions

Write the C++ statements as indicated by the comments.

Execute the program by clicking the "Run Code" button at the bottom of the screen.

========= Given Code =========

// Calculator.cpp - This program performs arithmetic, ( +. -, *. / ) on two numbers.
// Input: Interactive
// Output: Result of arithmetic operation

#include <iostream>
#include <string>
using namespace std;

// Write performOperation() function declaration here

int main()
{
double numberOne, numberTwo;
string operation;
double result;

cout << "Enter the first number: ";
cin >> numberOne;
cout << "Enter the second number: ";
cin >> numberTwo;
cout << "Enter an operator (+.-.*,/): ";
cin >> operation;

// Call performOperation method here

cout << numberOne;
cout << " " << operation << " ";
cout << numberTwo;
cout << " = ";
cout << result << endl;

return 0;

} // End of main() function

// Write performOperation function here

Reference no: EM132217412

Questions Cloud

Display student data including students average score : Display student data including students average score and letter grade. Prompt the user for a valid class size.
What percentage of time is the server idle : The average service time at the CSUS Financial Aid Office is 5.9 minutes. what percentage of time is the server idle?
Complete until goals are set and performance is measured : An advertising campaign plan is never complete until goals are set and performance is measured.
Take time to play around with different ways to represent : Take time to play around with different ways to represent the data (lines, dots, triangles, different colors).
Calculator that prompts the user for two numbers : In this lab, you complete a partially written C++ program that includes a function that returns a value.
What factors lead to project management success : ‘what factors lead to project management success What factors lead to a successful project?'' and ‘‘what factors are key to the specifics of the project
How to improve the processes in the given area : One of your clients, Gravina Gravel, is interested in improving the quality of its financial reporting and has asked for your advice regarding how to improve.
What is the expected number of customers in the system : Drop-in customers arrive at the Department of Motor Vehicles at a rate of 19.2 per hour. What is the expected number of customers in the system?
Design an inheritance hierarchy to include classes : Design an inheritance hierarchy to include classes for Student, GraduateStudent, and UnderGraduate and show it in the form of UML diagram.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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