Ans
code:-
#include <iostream>
#include<string>
using namespace std;
int solution(string s,int num1,int num2){
//if operation is addition
if(s=="+")
return num1+num2;
//if operation is subtraction
else if(s=="-")
return num1-num2;
//if operation is multiplication
else if(s=="*")
return num1*num2;
//if operation is division
else if(s=="/"){ //divide by zero
if(num2==0) return -2;
return num1/num2;}
//if operation is max
else if(s=="max")
{//if num1 is max
if(num1>num2) return num1;
else return num2;}
//if operation is to find the min
else if(s=="min") {
//if num1 is min
if(num1<num2) return num1;
else return num2;
}
//if no match return -1
return -1;
}
int main()
{
string s;
int num1,num2;
cin>>s;
cin>>num1;
cin>>num2;
cout<<solution(s,num1,num2);
return 0;
}

If any doubt ask in the comments.
CC++ Compiler: CPP (gcc-5.x) 0 Simple Calculator Given two integers and a string, create a simple...
//Find two smallest integers #include <iostream> #include <string> using namespace std; // implement printArray here // implement findTwoSmallest here // DO NOT WRITE ANY CODE BELOW THIS LINE (EXCEPT FOR TESTING - REMOVE BEFORE SUBMITTING) int main() { int n; int arr[100]; cout << "Enter number of integers: "; cin >> n; cout << "Enter " << n << " integers: "; for(int i = 0; i < n; i++) { ...
Write an ARM program that implements a simple four-function calculator and prompts the user to enter a pair of decimal integers (A and B) followed by a character that specifies one of the operators: ‘+’ for addition to compute A+B ‘-‘ for subtraction to compute A-B ‘*’ for multiplication to produce the product A*B ‘/’ for division to produce the quotient A/B. Input should be the pair of numbers followed by the operand followed by a return. For example...
// Assignment11.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <string> using namespace std; int main() { int size, m, n, c, d, first[10][10], second[10][10], sum[10][10]; cout << "Enter the number of rows and columns of matrices: "; cin >> size; m = size; n = size; cout << "Enter the elements of first matrix: "; for ( c = 0 ; c < m ; c++ ) for ( d = 0...
Write an ARM program that implements a simple four-function calculator and prompts the user to enter a pair of decimal integers (A and B) followed by a character that specifies one of the operators: ‘+’ for addition to compute A+B ‘-‘ for subtraction to compute A-B ‘*’ for multiplication to produce the product A*B ‘/’ for division to produce the quotient A/B. Input should be the pair of numbers followed by the operand followed by a return. For example...
1. Specification Write a C program to implement a simple calculator that accepts input in the following format and displays the result of the computation: calc [operand_1] [operator] [operand_2] The operands operand_1 and operand_2 are non-negative integers. The operator is one of the following: addition (+), subtraction (-), multiplication (x), division (/) and modulo (%). Note: For the multiplication operator, use letter ‘x’. If you use the asterisk ‘*’, your program will not work properly 2. Implementation • The program...
Using Python.
3) Create a single-linked list (StudentList) where the data in the link is an object of type pointer to Student as defined below. Note that you need to store and pass a pointer of type Student so that you do not create duplicate objects. Test your list with the provided program. You will find example code for a single-linked list of integers in Moodle that you can base your solution on. For your find methods, you can either...
The Calculator Class Create an application dlass called Colcustor with the following members Methods Retuns firtNumber secondumber static void mainsering Asks for two integer undan uiet", ..",ЛТеп shows the result according to Note Use the attached example program and add required methods. Then une a switch tructure in the try black to call proper method according to the input operator Sample Output 1 : 2074 Sample Output 2 D1VLdeBy LerOWLthEkceptionHahaling-Jav / Handling ArithmeticExceptions and InputMismatchExceptions. import java.util.InputMismatchException; import java.util.Scanner; public...
Write a C/C++ program that simulate a menu based binary number calculator. This calculate shall have the following three functionalities: Covert a binary string to corresponding positive integers Convert a positive integer to its binary representation Add two binary numbers, both numbers are represented as a string of 0s and 1s To reduce student work load, a start file CSCIProjOneHandout.cpp is given. In this file, the structure of the program has been established. The students only need to implement the...
I'm just a beginner in programming,how to make this program more simple without using #include<iostream> and #include<redex> here is the question Terms to know: If-else statement,for..while..do while,loops,pointer,address,continue,return,break. Create a C++ program which contain a function to ask user to enter user ID and password. The passwordmust contain at least 6 alphanumeric characters, 1 of the symbols !.@,#,$,%,^,&,* and 1 capital letter.The maximum allowable password is 20. Save the information. Test the program by entering the User ID and password. The...
Programming Concepts cin/cout variables/types Functions Reference structs Task Summary: For this first Quest you I have set up a program in Visual Studio that will use operation between fractions. I have written a basic code example that does all the resources that you need to follow. Your job is to complete the exercises presented below in quest2.cpp. For this assignment you will learn and demonstrate how to: Work with functions use Past-by-Value and Past-by-Reference. use structs. use cin to get...