Write a program that asks the user for two integers and a character, 'A', 'S', or 'M'.
Not what you're looking for?
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;
}
Purchase this Solution
Solution Summary
Write a program that asks the user for two integers and a character, 'A', 'S', or 'M'.
Purchase this Solution
Free BrainMass Quizzes
Basic Networking Questions
This quiz consists of some basic networking questions.
C++ Operators
This quiz tests a student's knowledge about C++ operators.
Word 2010: Table of Contents
Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.
Javscript Basics
Quiz on basics of javascript programming language.
Excel Introductory Quiz
This quiz tests your knowledge of basics of MS-Excel.