Question

In: Computer Science

NEED TO DEBUG // This pseudocode should create a report that contains an // apartment complex...

NEED TO DEBUG

// This pseudocode should create a report that contains an
// apartment complex rental agent's commission. The
// program accepts the ID number and name of the agent who
// rented the apartment, and the number of bedrooms in the
// apartment. The commission is $100 for renting a three-bedroom
// apartment, $75 for renting a two-bedroom apartment, $55 for
// renting a one-bedroom apartment, and $30 for renting a studio
// (zero-bedroom) apartment. Output is the salesperson’s
// name and ID number and the commission earned on the rental.
start
Declarations
num salesPersonID
string salesPersonName
num numBedrooms
num COMM_3 = $100.00
num COMM_2 = $75.00
num COMM_1 = $55.00
num COMM_STUDIO = $30.00
num QUIT = 9999
getReady()
while salesPersonID <> QUIT
detailLoop()
endwhile
finish()
stop

getReady()
output "Enter salesperson ID or ", QUIT, " to quit "
output salesperson_ID
return

detailLoop()
output "Enter name "
input salesPersonName
output "Enter number of bedrooms rented "
input numBedrooms
if numBedrooms > 3 then
commissionEarned = COMM_3
else
if numBedrooms < 2 then
commissionEarned = COMM_2
else
if numBedrooms > 1 then
commission = COMM_1
else
commission = COMM_4
endif
endif
endif
output salesPersonID, salesPersName, commissionEarned
output "Enter salesperson ID or ", QUIT, " to quit "
input salesPersonID
return

finish()
output "End of report"
return

Solutions

Expert Solution

Pseudo code :

start

num QUIT = 9999;

   num salesPersonID
   string salesPersonName
   num numBedrooms
   const num COMM_3 = 100
   const num COMM_2 = 75
   const num COMM_1 = 55
   const num COMM_STUDIO = 30
   num commissionEarned=0

   Call getReady() read return value in salesPersonID

   while salesPersonID != QUIT Then
       output "Enter name ";
       cin>> salesPersonName;
       output "Enter number of bedrooms rented ";
       cin>> numBedrooms;
       if (numBedrooms == 3 ) Then
           commissionEarned = COMM_3;
       else if (numBedrooms == 2 ) Then
           commissionEarned = COMM_2;
       else if( numBedrooms == 1 ) Then
           commissionEarned = COMM_1;
       else
           commissionEarned = COMM_STUDIO;
       end if

       output salesPersonID, salesPersonName, commissionEarned

       Call getReady() read return value in salesPersonID
   End while loop

stop

getReady()
   num salesperson_ID
   output "Enter salesperson ID or "<< QUIT<< " to quit "
   input salesperson_ID
return salesperson_ID

------------------------------------------------------------------------------------------------------

C++ code of pseudocode:


//main.cpp
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int getReady();
int QUIT = 9999;
int main()
{
   int salesPersonID;
   string salesPersonName;
   int numBedrooms;
   const int COMM_3 = 100;
   const int COMM_2 = 75;
   const int COMM_1 = 55;
   const int COMM_STUDIO = 30;
   int commissionEarned=0;

   salesPersonID=getReady();

   while (salesPersonID != QUIT)
   {
       cout<< "Enter name ";
       cin>> salesPersonName;
       cout<< "Enter number of bedrooms rented ";
       cin>> numBedrooms;
       if (numBedrooms == 3 )
           commissionEarned = COMM_3;
       else if (numBedrooms == 2 )
           commissionEarned = COMM_2;
       else if( numBedrooms == 1 )
           commissionEarned = COMM_1;
       else
           commissionEarned = COMM_STUDIO;

       cout<<left<<setw(10)<<"Person#ID"
               <<setw(10)<<"Name"
               <<setw(10)<<"Commission"<<endl;
       cout<<left<<setw(10)<<salesPersonID
               <<setw(10)<<salesPersonName
               <<setw(10)<<commissionEarned<<endl;

           salesPersonID=getReady();
   }

   system("pause");
   return 0;
}
/*Function that prompt for sales person id and returns
the sales person id value.*/
int getReady()
{
   int salesperson_ID;
   cout<< "Enter salesperson ID or "<< QUIT<< " to quit ";
   cin>> salesperson_ID;
   return salesperson_ID;
}

------------------------------------------------------------------------------------------------------

Sample Output:


Related Solutions

NEED TO DEBUG // This pseudocode should create a list that describes annual profit // statistics...
NEED TO DEBUG // This pseudocode should create a list that describes annual profit // statistics for a retail store. Input records contain a department // name (for example, “Cosmetics”) and profits for each quarter for // the last two years. The program should determine whether // the profit is higher, lower, or the same // for this full year compared to the last full year. start Declarations string department num salesQuarter1ThisYear num salesQuarter2ThisYear num salesQuarter3ThisYear num salesQuarter3ThisYear num salesQuarter1LastYear...
I NEED TO DEBUG THIS PSUEDOCODE // This pseudocode should determine and output the rental fees...
I NEED TO DEBUG THIS PSUEDOCODE // This pseudocode should determine and output the rental fees for cars. // Standard cars rent for $65 per day, compacts rent for $40 per day, // and subcompacts rent for $30 per day. Rentals for at least 7 days // receive a 20% discount. An error message is displayed if the car type // is not valid. start Declarations string carType num days num STD_RATE = 65 num COM_RATE = 40 num SUB_RATE...
In this exercise, you will test and debug a Future Value Program. The pseudocode of the...
In this exercise, you will test and debug a Future Value Program. The pseudocode of the program is as follows: Display user message WHILE user wants to continue           get monthly investment, yearly interest rate, and years           convert yearly interest rate to monthly interest rate           convert years to months           set the future value to zero           FOR each month                     add monthly investment amount to future value                     calculate interest for month                     add interest to future value          ...
In this exercise, you will test and debug a Future Value Program. The pseudocode of the...
In this exercise, you will test and debug a Future Value Program. The pseudocode of the program is as follows: Display user message WHILE user wants to continue           get monthly investment, yearly interest rate, and years           convert yearly interest rate to monthly interest rate           convert years to months           set the future value to zero           FOR each month                     add monthly investment amount to future value                     calculate interest for month                     add interest to future value          ...
(matlab) Since the problem is fairly complex, it may be better to complete & debug the...
(matlab) Since the problem is fairly complex, it may be better to complete & debug the program offline, then submit in Grader. In this exercise you will complete a simplified program to play a hand of Blackjack. The goal is to complete a modular program using local and anonymous functions. Although there are several functions that must be written, they are all quite short and simple, just 1 to 4 lines. The most important learning objective is to understand how...
Design a program using pseudocode to produce a report showing recommended sale prices. The program should...
Design a program using pseudocode to produce a report showing recommended sale prices. The program should ask the user to enter the item number, last sale date, number of items on hand, current date, item cost and the regular selling price. The program will output the item number, last sale date, days elapsed, number of item on hand, item cost, regular selling price and sales price. If the item has not been placed on sale for the last 30 days,...
You are considering the purchase of an apartment complex. The following assumptions are made: • The...
You are considering the purchase of an apartment complex. The following assumptions are made: • The purchase price is $1,150,000. • Potential gross income (PGI) for the first year of operations is projected to be $195,000. • PGI is expected to increase at 4 percent per year. • 3% vacancies are expected. • Operating expenses are estimated at 30 percent of effective gross income. Capital expenditures are estimated at 10 percent of effective gross income. • The market value of...
You are considering the purchase of an apartment complex. The following assumptions are made: •           The...
You are considering the purchase of an apartment complex. The following assumptions are made: •           The purchase price is $1,250,000. •           Potential gross income (PGI) for the first year of operations is projected to be $191,000. •           PGI is expected to increase at 4.5 percent per year. •           5% vacancies are expected. •           Operating expenses are estimated at 35 percent of effective gross income. Capital expenditures are estimated at 15 percent of effective gross income. •           The market value of...
Allen Benedict is thinking of buying an apartment complex that is offered for sale by the...
Allen Benedict is thinking of buying an apartment complex that is offered for sale by the firm of Getz and Fowler. The price, $2.25 million, equals the property's market value. The following statement of income and expense is presented for Benedict's consideration: The St. George Apartments Prior Year's Operating Results, Presented by Gertz and Fowler, Brokers 30units, all 2-bedroom apartments, $975/month $351,000 water & dryer rentals 10,000 gross annual income $361,000 Less operating expenses: Manager's salary $10,000 Maintenance staff (1...
You own five apartment complexes. You created a dataset listing the apartment numbers, apartment complex names, number of bedrooms, rental price, whether the apartment is occupied or not, and the date the apartment was last remodeled.
You own five apartment complexes. You created a dataset listing the apartment numbers, apartment complex names, number of bedrooms, rental price, whether the apartment is occupied or not, and the date the apartment was last remodeled. You want to insert some functions to perform calculations to help you decide which apartments need to be remodeled. To focus on the apartments that need to be remodeled, you will use advanced filtering and database functions for your analysis. Finally, you are considering...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT