Program that asks the user for two integers and a character

Assignment Help C/C++ Programming
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

Reference no: EM13938487

Questions Cloud

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.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Find answers of c programming questions

1. int main(void){ int height 3. 5; int width = 25: if(height == 5 && width == 25){printf("the height and width are correct: "); }return 0; }Assuming all libraries are included, what is the result of the code above when run?

  Write an interactive program that prompts for a desired sum

Write an interactive program that prompts for a desired sum, then repeatedly rolls two six-sided dice until their sum is the desired sum. Here is the expected dialogue with the user.

  Lab9 c lab 9 c i request this twice but no answer on this

lab 9 c ltbrgti request this twice but no answer on this please could you check this for

  Generate a set of 75 random integers in the range -26 to + 4

Write a program that will generate a set of 75 random integers in the range -26 to + 42. The program

  One the same set of axes

One the same set of axes, plot the monopolist's demand and marginal revenue curves. Indicate where theprice elasticity of demand is elastic, inelastic and unit elastic.

  Class named realestate that has data members

Create a class named RealEstate that has data members to hold the price of a house, the number of bedrooms, and the number of baths. Member functions include overloaded insertion and extraction operations

  Program to implement a user defined function

Write a C++ program that uses user-defined functions to read three integer numbers from the user, compute the summation, difference, and product of these numbers, and print the results on the screen.

  1 recursive sorts are easier to write in functional style

1 recursive sorts are easier to write in functional style than others. two recursive sorts are quicksort and mergesort.

  Implement the guess the word

Implement  the ‘Guess the Word' game in an object-oriented manner

  The westfield carpet company has asked you to write an

the westfield carpet company has asked you to write an application that calculates the price of carpeting for

  Write a function - greatest common divisor

Write a function named "g_c_d" that takes two positive integer arguments and returns as its value the greatest common divisor of those two integers.

  Construct the wait-for graph

P2 waits for 2 units of R1 and holds 1 unit of R2, P3 holds 2 units of R3 and waits for 1 unit of R4, P4 holds 2 units of R3 and waits for 1 unit of R4. Construct the wait-for graph. Does the system have a deadlock? Justify your answer

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