I am new to ctt programming and I am having some problems trying to get an understanding of what this programming is all about.
The following program is the code. Note that in the program we must include the requirement that the program end if the user inputs an invalid property code. I have been asked to Re-write this program by replacing switch statement by if statements. Then make a screenshot of the program output on my computer. Here's the program:
// prob04-3. cpp
// This program determines the commission on real estate sales
// depending on the type of property sold.
#include <iostream>
#include <iomanip>
#include <cstd1ib>
using namespace std;
int main ()
{
const double RESIDENTIAL_RATE + 0.060;
const double MULTIDWELLING_RATE = 0.050;
cont double COMMERCIAL_RATE = 0.045;
int property_code;
double sale_price,
commission_rate,
commission;
cout << setprecision (2)
<< setiosflags (ios::fixed)
<< setiosflags (ios::showpoint) ;
cout << "Enter the property's selling price: ";
cin >> sale price;
cout << end1 ;
cout << "Enter the property code according to the following."
<< end1 << end1 ;
cout << "Residental, enter R" << end1;
cout << "Multiple Dwelling, enter M" << end1;
cout Commercial, enter C" << end1 << end1;
cout << "Please make your selection: :;
cin. get () ; // Discard the \n
property_code = cin.get () ;
switch (property_code)
{
case 'R' :
case 'r' :
commission_rate = RESIDENTAL_RATE;
break;
case 'M' :
case 'm' :
commission_rate = COMMERCIAL_RATE;
break;
default:
cout << end1 << end1
<<"Invalid Property Code! Try Again" << end1;
edit (1) ;
break
}
commission = sale_price * commission_rate;
cout << end1 << end1;
cout << "The commsiion is " << commission << end1;
return 0;
}
Program Output: Enter the property's selling price: 270000
Enter the property's code according to the following:
Residental, enter R
Multiple Dwelling enter M
Commercial, enter C
Please make your selection R
The commission is 16200.00