Answered step by step
Verified Expert Solution
Link Copied!

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 100 books and determines a price for
// each. The price is 10 cents per page for the first 200 pages, then 8
// 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 =100
Book books[]
num sub
sub =0
while sub <= SIZE
books[]= getBookValues(sub)
sub = sub +1
end
displayBooks(books, sub)
stop
private static Book getBookValues()
// Declarations
Book book
string title
num pages
num price
num MIN_PAGES =200
num HIGH_PRICE =0.10
num LOW_PRICE =0.08
output "Enter title ..."
output title
output "Enter pages ..."
output pages
book.setTitle(pages)
book.setPages(title)
if pages < MIN_PAGES then
price = pages + HIGH_PRICE
elseif
price = MIN_PAGES + HIGH_PRICE +(pages MIN_PAGES)+ LOW_PRICE
end
book.setPrice(price)
return item
public static void displayBooks(Book[] books, num SIZE)
// Declarations
int x
x =0
while x <= SIZE
output "Title: ", books[SIZE].getTitle()
output "Pages: ", books[SIZE].getPages()
output "Price: ", books[SIZE].getPrice()
x = x +1
end
return
class Book
// Declarations
private string title
private num pages
private num price
public void setTitle(int bookTitle)
title = booktitle
return
public int setPages(num pages)
this.pages = pages
return
public int setPrice(num 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 23rd International Conference Dexa 2012 Vienna Austria September 2012 Proceedings Part 1 Lncs 7446

Authors: Stephen W. Liddle ,Klaus-Dieter Schewe ,A Min Tjoa ,Xiaofang Zhou

2012th Edition

3642325998, 978-3642325991

More Books

Students also viewed these Databases questions