Endif endif endif else exception mistake throw

This preview shows page 20 - 24 out of 34 pages.

1.A file named MAINTENANCE11-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.
// Modify the program to use a Product class to// hold product data. Include a constructor// that accepts all the data fields as parameters.class ProductDeclarationsprivate string idNumprivate string descriptionprivate num pricepublic Product(string id, string descrip, num pr)idNum = iddescription = descripprice = prreturnpublic void setIdNum(string id)idNum = idreturnpublic void setDescription(string des)description = desreturnpublic void setPrice(num pr)if pr < 0price = 0elseprice = prendifreturnpublic string getIdNum()return idNumpublic string getDescription()return descriptionpublic num getPrice()return priceendClassstartDeclarationsnum SIZE = 100Product products[SIZE]num x = 0num total = 0num avgnum highestPrice = 0string highestIdstring higestDescripwhile x < SIZEproducts[x] = getData()total = total + products[x].getPrice()if products[x].getPrice() > highestPricehighestPrice = products[x].getPrice()highestDesc = products[x].getDescription()highestId = products[x].getIdNum()
endifx = x + 1endwhileavg = total / SIZEoutput "The highest priced product is highestId,highestDescrip, " $", highestPriceoutput "The average price of all products is $", avgstopProduct getData()string idstring descripnum priceoutput "Enter id or "input idoutput "Enter description "input descripoutput "Enter price "input priceProduct p(id, descrip, price)return pFind the Bugs1.Your downloadable files for Chapter 11 include DEBUG11-01.txt, DEBUG11-02.txt, and DEBUG11-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 find and correct.
returnpublic Patient(string id, string last, string first)idNum = id // field is idNumlastName = lastfirstName = firstreturnpublic void display() // display() is a void methodoutput "Patient #", idNum, lastName, firstNamereturnendClassstartDeclarationsPatient patient1Patient patient2("234", "Lee", "Lydia")patient1.display()patient2.display()stopDEBUG 11-02// This file defines the Building class

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture