#1) I need the source code for a C++ program that has many functions. The program should prompt user to enter 2 numbers and math opeator (+=)(+-) and display the results bas on math operator.
#2) Write another C++ program for a college (MATS COLLEGE), they want to have a ATM machine:
- Enter balance
- Transactions:
(a) Deposit
(b) Withdrawal
if withdrawal more than balance, program should display "insufficient funds".
PLEASE HELP ME!!!
#include <stdio.h>
void main()
{
float ans=0;
float num1=0;
float num2=0;
int check=0;
char s[8];
char theop = ' ';
//prompt the user:
printf("Enter 2 numbers and a math operator in the format specified\n");
printf("\nValid Operators: +, -\nFormat:NUMBER1 NUMBER2 OPERATOR\n e.g.\n4.7 5.2 +\n\n");
//get the user input
scanf("%f %f %c", &num1, &num2, &theop);
//interpret the operator and do a calculation
switch(theop)
{
case '+':
ans = num1 + num2;
check = 1;
break;
case '-':
ans = num1 - num2;
check = 1;
break;
default:
check = 0;
break;
}
//print the answer
if (check == 1)
printf ("Answer: %f\n\n", ans);
else
printf("%c is not a valid operator", theop);
}