Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
This program accepts data about books and determines a price for
each. The price is cents per page for the first pages, then
cents per page after that. After pricing, all the data is displayed.
The user has created a Book class with some methods but there are
some errors that need fixing.
start
Declarations
num SIZE
Book books
num sub
sub
while sub SIZE
books getBookValuessub
sub sub
end
displayBooksbooks sub
stop
private static Book getBookValues
Declarations
Book book
string title
num pages
num price
num MINPAGES
num HIGHPRICE
num LOWPRICE
output "Enter title
output title
output "Enter pages
output pages
book.setTitlepages
book.setPagestitle
if pages MINPAGES then
price pages HIGHPRICE
elseif
price MINPAGES HIGHPRICE pages MINPAGES LOWPRICE
end
book.setPriceprice
return item
public static void displayBooksBook books, num SIZE
Declarations
int x
x
while x SIZE
output "Title: booksSIZEgetTitle
output "Pages: booksSIZEgetPages
output "Price: booksSIZEgetPrice
x x
end
return
class Book
Declarations
private string title
private num pages
private num price
public void setTitleint bookTitle
title booktitle
return
public int setPagesnum pages
this.pages pages
return
public int setPricenum pr
pr price
return
public int getTitle
return title
public int getPages
return pages
public int getPrice
return price
endClass
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started