Question

write a c++ program.

A real estate broker sets fees for selling properties according to the property type as shown in the table. The broker wants

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// C++ program to calculate the gross and net commission of a real estate broker

#include <iostream>

#include <cctype>

#include <iomanip>

using namespace std;

int main() {

               char property_code, broker_code;

               double sale_price, gross_commission, net_commission;

               // input of broker type

               cout<<"Enter Broker type( I, A or F) : ";

               cin>>broker_code;

               // validate broker code

               if((toupper(broker_code) != 'I') && (toupper(broker_code) != 'A') && (toupper(broker_code) != 'F'))

               {

                              cout<<"Invalid Broker Code. Valid Broker codes are I , A or F"<<endl;

                              return 1;

               }

               // input of property code

               cout<<"Enter property code(R, C, G) : ";

               cin>>property_code;

               // validate property code

               if((toupper(property_code) != 'R') && (toupper(property_code) != 'C') && (toupper(property_code) != 'G'))

               {

                              cout<<"Invalid Property Code. Valid Broker codes are R , C or G"<<endl;

                              return 1;

               }

               // input of sale price

               cout<<"Enter the sale price of property : ";

               cin>>sale_price;

               // switch statement to calculate the gross commission of the broker

               switch(property_code)

               {

                              case 'R':

                              case 'r':

                                             gross_commission = sale_price*0.06;

                                             break;

                              case 'C':

                              case 'c':

                                             gross_commission = sale_price*0.047;

                                             break;

                              case 'G':

                              case 'g':

                                             gross_commission = sale_price*0.04;

                                             break;

               }

               // if sale price is >= 15,000,000 then add additional 2.5% commission

               if(sale_price >= 15000000)

                              gross_commission += (sale_price*0.025);

               //switch statement to calculate the net commission

               switch(broker_code)

               {

                              case 'I':

                              case 'i':

                                             net_commission = gross_commission - (gross_commission*0.2);

                                             break;

                              case 'A':

                              case 'a':

                                             net_commission = gross_commission - (gross_commission*0.25);

                                             break;

                              case 'F':

                              case 'f':

                                             net_commission = gross_commission - (gross_commission*0.1);

                                             break;

               }

               // output

               cout<<"Gross Commission : $"<<fixed<<setprecision(2)<<gross_commission<<endl;

               cout<<"Net Commission : $"<<fixed<<setprecision(2)<<net_commission<<endl;

               return 0;

}

//end of program

Output:

Enter Broker type( I, A or F) a Enter property code(R, C, G) : G Enter the sale price of property 17500000 Gross Commission $

Add a comment
Know the answer?
Add Answer to:
write a c++ program. A real estate broker sets fees for selling properties according to the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program that does the following: • Displays a menu (similar to what you...

    Write a C program that does the following: • Displays a menu (similar to what you see in a Bank ATM machine) that prompts the user to enter a single character S or D or Q and then prints a shape of Square, Diamond (with selected height and selected symbol), or Quits if user entered Q. Apart from these 2 other shapes, add a new shape of your choice for any related character. • Program then prompts the user to...

  • In this program, you will be using C++ programming constructs, such as overloaded functions. Write a...

    In this program, you will be using C++ programming constructs, such as overloaded functions. Write a program that requests 3 integers from the user and displays the largest one entered. Your program will then request 3 characters from the user and display the largest character entered. If the user enters a non-alphabetic character, your program will display an error message. You must fill in the body of main() to prompt the user for input, and call the overloaded function showBiggest()...

  • Write a javascript program that prompts for the price and the tax rate for shopping in...

    Write a javascript program that prompts for the price and the tax rate for shopping in a store. Calculate and display the tax amount and total price. For example, if the user enters 100 for the price and 7% as the tax rate, the program should displays $107.00 as the total price and $7.00 as the tax amount.

  • (PYTHON) Stock Transaction Program Last month Joe purchased some stock from StockTrade.   1. Write a function(s)...

    (PYTHON) Stock Transaction Program Last month Joe purchased some stock from StockTrade.   1. Write a function(s) to allow the user to input the followings: ·The name of the stock ·Number of shares Joe bought · Stock purchase price · Stock selling price ·Broker commission 2. Write function(s) to calculate: and: · The amount of money Joe paid for the stock (number of shares bought * purchase price) · The amount of commission Joe paid his broker when he bought the...

  • Using the Arduino IDE, write a program for an Arduino board that will perform the following three...

    Using the Arduino IDE, write a program for an Arduino board that will perform the following three tasks: 1. Input: Prompt the user to enter a character string. Read the character string from your computer through the Arduino's serial interface. 2. Processing: Convert lowercase characters to uppercase and uppercase characters to lowercase, and 3. Output: Return the processed string through the serial output and display it on your computer screen. Example: If the input character string is, “Here I am”,...

  • Write a C program that asks the user to enter two real numbers. Then your program...

    Write a C program that asks the user to enter two real numbers. Then your program displays a menu that asks the user to choose what arithmetic operation to be done on those numbers. Depending on the user's entry, the program should display the result to the screen. The sample runs below show what should be done to the numbers entered by the user. Your program should run exactly like shown in the sample runs. make your code run as...

  • Write a program (C++) that shows Game sales. The program should use a structure to store...

    Write a program (C++) that shows Game sales. The program should use a structure to store the following data about the Game sale: Game company Type of Game (Action, Adventure, Sports etc.) Year of Sale Sale Price The program should use an array of at least 3 structures (3 variables of the same structure). It should let the user enter data into the array, change the contents of any element and display the data stored in the array. The program...

  • Structures in C++ :- 1. Write a program that declares a structure to store the code...

    Structures in C++ :- 1. Write a program that declares a structure to store the code number, salary and grade of an employee. The program defines two structure variables, inputs record of two employees and then displays the record of the employee with more salary. 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then...

  • Palindrome Detector C++ A palindrome is any word, phrase, or sentence that reads the same forward...

    Palindrome Detector C++ A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Able was I, ere I saw Elba A man, a plan, a canal, Panama Desserts, I stressed Kayak Write a program that determine whether an input string is a palindrome or not. Input: The program should prompt the user "Please enter a string to test for palindrome or type QUIT to exit: " and then wait for...

  • You are to write a program IN C++ that asks the user to enter an item's...

    You are to write a program IN C++ that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: if the an item's wholesale cost is 5.00 and its markup percentage is 100%, then the item's retail price is 10.00 If an item's wholesale cost is 5.00 and its markup percentage is 50%, then the item's retail price is 7.50 Program design specs. You should have 5...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT