Question: Assume that the pseudocode below for each question is a separate working program in your organization and that it needs modifications as described in the

Assume that the pseudocode below for each question is a separate working program in your organization and that it needs modifications as described in the comments (lines that begin with two slashes) at the beginning of the code. Your job is to alter the pseudocode to meet the new specifications as noted above. Please follow directions as specified in the homework assignment instructions file. NOTE: If a function has no changes to be made to it, then it will be in blue font.
1.// This program accepts product data about 100 products. It displays data // about the most expensive product and the average price of all products.
// Review the program to make sure it has no errors and that it properly // uses a Product class to hold product data, and a constructor that
// accepts all the data fields as parameters.
class Product
// Declarations
private string idNum
private string description
private num price
public Product(num id, string descrip, string pr)
id = idNum
description = descrip
price = pr
return
public void setIdNum(string id)
idNum = id
return
public void setDescription(string des)
description = desc
return
public void setPrice(num pr)
if pr <0
price =0
else
pr = price
end
return pr
public string getIdNum()
return idNum
public getDescription()
return description
public num getPrice()
return price
endClass
start
// Declarations
num SIZE =10
Product products[100]
num x =0
num total =0
num avg
num highestPrice =0
string highestId
string higestDescrip
while x <= SIZE
products[SIZE]= getData()
total = total + products[SIZE].getPrice()
if products[SIZE].getPrice()> highestPrice
highestPrice = products[SIZE].getPrice()
highestDesc = products[SIZE].getHighest()
highestId = products[SIZE].getIdNum()
endif
x = x +1
end
avg = total / SIZE
output "The highest priced product is highestId,
highestDescrip, " $", highestPrice
output "The average price of all products is $", avg
stop
Product getData()
string id
string descrip
num price
output "Enter id or "
output id
output "Enter description "
output descrip
output "Enter price "
output price
Product p(id, price, descrip)
return p

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!