In: Computer Science
Write a program that can be used to calculate the commission
earned in a real estate transaction. The chart below describes the
formulas used to calculate the commission. Your program will ask
the user for the sales price as an double, calculate the
commission, and display the sales price and commission. Remember to
use constants rather than “magic numbers”.
Sales Price Commission Less than $100,000 5% of the sales price
$100,000 to $300,000 $5,000 + 10% of the amount of the sales price
over $100,000 More than $300,000 $25,000 + 15% of the amount of the
sales price over $300,000
2. Write a program that acts as a simple calculator. You will ask
the user to enter two integers. Then you will ask for an operator
from the list *,/,%,+, and -. If the user does not enter a valid
operator, you will report the error and not perform any action. If
the user asked to do division and the second number is zero, you
will report the error and not perform any action. Otherwise, you
will display what the equation is and the result
1: C++:
#include <iostream>
using namespace std;
int main() {
double sale,commision;
cout<<"Enter sale Amount: $";
cin>>sale;
if(sale<100000){
commision=0.05*sale;
}
else if(sale>=100000 && sale<300000){
commision=5000+((sale-100000)*0.10);
}
else{
commision=25000+((sale-300000)*0.15);
}
cout<<"Sale Amount= $"<<sale<<endl;
cout<<"Commision=: $"<<commision;
}
2)
#include <iostream>
using namespace std;
int main() {
int a,b;
char ch;
cout<<"Enter integer 1: ";
cin>>a;
cout<<"Enter integer 2: ";
cin>>b;
cout<<"Enter one out of following: +,-,*,/,% ";
cin>>ch;
if(ch=='+')
cout<<"The result of "<<a<<"+"<<b<<" is "<<(a+b);
else if(ch=='-'){
cout<<"The result of "<<a<<"-"<<b<<" is "<<(a-b);
}
else if(ch=='*'){
cout<<"The result of "<<a<<"*"<<b<<" is "<<(a*b);
}
else if(ch=='/'){
if(b==0){cout<<"Error, Cannot divide with 0"; }
else{
cout<<"The result of "<<a<<"/"<<b<<" is "<<(double)(a/b);}
}
else if(ch=='%'){
cout<<"The result of "<<a<<"%"<<b<<" is "<<(a%b);
}
else
cout<<"Invalid input";
}
if you like the answer please provide a thumbs up.