Reference no: EM13938487
Write a program that asks the user for two integers and a character, 'A', 'S', or 'M'. Call one of three functions that adds, substracts, or multiplies the user's integers, based on the character input.
This is what I have so far but I cant figure out how to link the character data A, M, or S to the specific funtions.
#include<iostream>
using namespace std;
void main()
{
int a, b;
char c;
int result=0;
cout << " Please enter first integer: ";
cin>> a;
cout << " Please enter second integer: ";
cin>> b;
cout << "nnn(A) Additionnnn(M) Multiplicationnnn(S) SubstractionnnnPlease enter a character input: ";
cin>> c;
while (c!='A' && c!='a' && c!='M' && c!='m' && c!='S' && c!='s')
{
cout<<"Invalid selection.nnYou must enter a valid selection A, M, or S.nn"<<endl;
cout<<"Please enter a character input: ";
cin>>c;
cout<<endl;
}//end while
if (c == 'A' || c == 'a')
{
}
}
int resultAdd(int num1, int num2)
{
int result;
result = num1 + num2;
cout<<"The sum of two integers is: " <<result<<endl;
return result;
}
int resultMult(int num1, int num2)
{
int result;
result = num1 * num2;
cout<<"The multiplication of two integers is: " <<result<<endl;
return result;
}
int resultSub(int num1, int num2)
{
int result;
result = num1 - num2;
cout<<"The difference between two integers is: " <<result<<endl;
return result;
}
Attachment:- twoIntegers.zip
Depreciation is straight-line to zero over life of projects
: We are evaluating a project that costs $1089458, has a seven-year life, and has no salvage value. Assume that depreciation is straight-line to zero over the life of the project. Sales are projected at 40651 units per year. Suppose the projections giv..
|
Very large and rapid declines in the policy rate
: We observe very large and rapid declines in the policy rate (the very short rate) in late 2008 and early 2009. Considering the US, the UK, and Japan, did long rates fall as much around that time or less or more?
|
Calculate the expected full cost of the surenex engagement
: Calculate the expected full cost of the Surenex engagement, including an allocation of overhead.
|
Represents the second highest overhead
: For most organizations, the cost of built space represents the second highest overhead (OpEx) after staff costs. From critical consideration of the relevant research literature, your experience, and best practice in space management, consider the ..
|
Program that asks the user for two integers and a character
: Write a program that asks the user for two integers and a character, 'A', 'S', or 'M'. Call one of three functions that adds, substracts, or multiplies the user's integers, based on the character input.
|
Research a number of community organisations
: You are asked to research a number of community organisations (at least three) and construct a typology which demonstrates: what they do, how they approach management of the various aspects of their operations and how they demonstrate effectivenes..
|
Differences between channel proteins and carrier proteins
: Insulin increases glucose transport across the cell membrane of an adipocyte but not across the membrane of a liver cell. How can one hormone have two different effects?
|
C program that will fork a new process
: Write a C program that will fork a new process. The parent side has to sort the elements of an array of size 10 in ascending order, while the child process has to sort the same array in descending order using bubble sort technique.
|
How is the amount of a liability measured
: How is the amount of a liability measured? When are most liabilities recognized? What are current liabilities? Provide some common examples.
|