The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 314 Weeks Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
// The Mortgage class contains fields for mortgage
// number, customer name, price of house, down
// payment, mortgage amount, and mortgage rate,
// and methods to set and get the values.
// The mortgage number must be betwen 10000 and 59999 inclusive
// or else it is set to 0
// The down payemnt cannot be more than the price of the house
// If it is, an error message is displayed
// and the down payment is reduced
// The mortage amount is the difference between the house price
// and the down payment
// The mortgage rate differs for loans of different sizes
// Loans over $200,000 get a preferred rate
// The demonstration program instantiates three Mortgages and
// purposely assigns invalid values to some of the arguments;
// the class methods will correct the invalid values.
class Mortgage
Declarations
private num mortgageNumber
private string customer
private num price
private num downPayment
private num mortgageAmt
private rate
public void setMortgageNumber(num number)
num LOW_NUM = 10000
num HIGH_NUM = 59999
if number = HIGH_NUM then
mortgageNumber = 0
else
if number mortgageNumber = 0
else
number = mortgageNumber
endif
endif
return
public void setCustomer()
customer = cust
return
public void setPriceAndDown(num pr, num down)
if down > pr then
down = pr
output "Down payment being reduced to price of house"
endif
price = pr
downPayment = down
mortgageAmt = price * downPayment
setRate()
return
private void setRate()
Declarations
num LOW_RATE = 0.05
num HIGH_RATE = 0.06
num CUTOFF = 200000
if mortgageAmt > CUTOFF
rate = LOW_RATE
else
rate = HIGH_RATE
return
private void displayMortgage()
output "Mortgage #", mortgageNumber
output "Customer: ", customer
output "Price of house ", price
output "Down payment ", downPayment
output "Mortgage amount ", mortgageAmt
output "Rate ", rate
return
endClass
Â
start
Declarations
Mortgage loan1
Mortgage loan2
Mortgage loan3
loan1.setMortgageNumber(34556)
loan1.setCustomer("Jones")
loan1.setPriceAndDown(100000, 20000)
loan1.displayMortgage()
loan2.setMortgageNumber(34)
loan2.setCustomer("Johnson")
loan2.setPriceAndDown(300000, 30000)
loan2.displayMortgage()
loan3.setMortgageNumber(88849)
loan3.setCustomer("Jordan")
loan3.setPriceAndDown(180000, 181000)
loan3.displayMortgage()
stop
This pseudocode has problems in itÂ
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly