A file named maintenance10 01txt is included with

This preview shows page 21 - 25 out of 31 pages.

We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
JavaScript: The Web Warrior Series
The document you are viewing contains questions related to this textbook.
Chapter 7 / Exercise 14
JavaScript: The Web Warrior Series
Vodnik
Expert Verified
1.A file named MAINTENANCE10-01.txt is included with your downloadable student files. Assume that this program is a 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 file. Your job is to alter the program to meet the new specifications.
We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
JavaScript: The Web Warrior Series
The document you are viewing contains questions related to this textbook.
Chapter 7 / Exercise 14
JavaScript: The Web Warrior Series
Vodnik
Expert Verified
Programming Logic and Design, 8eSolutions 10-22// 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.// Create a Book class and modify the program to use// an array of Book objects instead of individual// data items.startDeclarationsnum SIZE = 100Book books[SIZE]num subsub = 0while sub < SIZEbooks[sub] = getBookValues()sub = sub + 1endwhiledisplayBooks(books, SIZE)stoppublic static Book getBookValues()DeclarationsBook bookstring titlenum pagesnum pricenum MIN_PAGES = 200num HIGH_PRICE = 0.10num LOW_PRICE = 0.08output "Enter title … "input titleoutput "Enter pages … "input pagesbook.setTitle(title)book.setPages(pages)if pages <= MIN_PAGES thenprice = pages * HIGH_PRICEelseprice = MIN_PAGES * HIGH_PRICE +(pages – MIN_PAGES) * LOW_PRICEendifbook.setPrice(price)return itempublic static void displayBooks(Book[] books, num SIZE)Declarationsint xx = 0while x < SIZEoutput "Title: ", books[x].getTitle()output "Pages: ", books[x].getPages() output "Price: ", books[x].getPrice()x = x + 1
Programming Logic and Design, 8eSolutions 10-23endwhilereturnclass BookDeclarationsprivate string titleprivate num pagesprivate num pricepublic void setTitle(string bookTitle)title = booktitlereturnpublic void setPages(num pages)this.pages = pagesreturnpublic void setPrice(num pr)price = prreturnpublic string getTitle()return titlepublic num getPages()return pagespublic num getPrice()return priceendClassFind the Bugs1.Your downloadable student files for Chapter 10 include DEBUG10-01.txt, DEBUG10-02.txt, and DEBUG10-03.txt. Each file starts with some comments that describe the problem. Comments are lines that begin with two slashes (//). Following the comments, each file contains pseudocode that has one or more bugs you must findand correct.
// The demonstration program instantiates four Date objects and// purposely assigns invalid values to some of the arguments;// the class methods will correct the invalid values.class DateDeclarationsprivate num monthprivate num dayprivate num yearpublic void setDate(num mo, num da, num yr)num HIGH_MONTH = 12num HIGHEST_DAYS[HIGH_MONTH] =
Programming Logic and Design, 8eSolutions 10-2431, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31// value for December was missingif mo > HIGH_MONTH thenmonth = HIGH_MONTHelseif mo < 1 thenmonth = 1elsemonth = moendifendifif da > HIGHEST_DAYS[month - 1] thenday = HIGHEST_DAYS[month - 1]

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture