Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Logics & Design Chapter 11 Performing Maintenance 1 Need to understand the Logic to the pseudocode & provide a flowchart A file name MAINTENANCE11-01.txt

Programming Logics & Design Chapter 11 Performing Maintenance 1

Need to understand the Logic to the pseudocode & provide a flowchart

A file name 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 modification as described in the comments (line that begin with two slashes) as the beginning of the file. Your job is to alter the program to meet the new specifications.

// This program accepts product data about 100 products. // It displays data about the most expensive product // and the average price of all products. // Modify the program to use a Product class to // hold product data. Include a constructor // that accepts all the data fields as parameters. class Product Declarations private string idNum private string description private num price

public Product(string id, string descrip, num 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 price = pr endif return public string getIdNum() return idNum public getDescription() return description public num getPrice() return price endClass

start Declarations num SIZE = 100 Product products[SIZE] num x = 0 num total = 0 num avg num highestPrice = 0 string highestId string higestDescrip while x < SIZE products[SIZE] = getData() total = total + products[x].getPrice() if products[x].getPrice() > highestPrice highestPrice = products[x].getPrice() highestDesc = products[x].getHighest() highestId = products[x].getIdNum() endif x = x + 1 endwhile 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 " input id output "Enter description " input descrip output "Enter price " input price Product p(id, descrip, price) return p

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_2

Step: 3

blur-text-image_3

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 Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions

Question

74 Motivation concepts and applications.

Answered: 1 week ago