COM 204 ASSIGNMENT 7 ASSIGNMENT 2 MODULE 7.docx -...

This preview shows page 1 - 4 out of 16 pages.

COM-204-OL01Professor06/2019Assignment 7Chapter 10Exercise 6A.Design a class named StockTransaction that holds a stock symbol (typically one tofour characters), stock name, and price per share. Include methods to set and getthe values for each data field. Create the class diagram and write the pseudocodethat defines the class.
B.Design an application that declares twoStockTransactionobjects and sets anddisplays their values.Pseudocode:startDeclarations
Stock Transactions stock1Stock Transactions stock2stock1.setStockSymbol(“MON”)stock1.setStockName(“Inside Money”)stock1.setPricePerShare(243.56)stock2.setStockName(“Interest Money”)stock2.setPricePerShare(523.36)output “Stock 1 Details:”output “Stock Symbol : “, stock1.getStockSymbol()output “Stock Name : “, stock1.getStockName()output “Price per share : “, stock1.getPricePerShare()output “Stock 2 Details:”output “Stock Symbol : “, stock2.getStockSymbol()output “Stock Name : “, stock2.getStockName()output “Price per share : “, stock2.getPricePerShare()stopC.Design an application that declares an array of15StockTransactionobjects. Prompt theuser for data for each object, and then display all the values.Pseudocode:startDeclarationsnum SIZE=15StockTransaction stocks [10]num subsub=0while substocks[sub]=getDetails()sub=sub+1endwhiledisplayAllDetails( stocks, SIZE)stoppublic static StockTransaction getDetails()DeclarationsStock Transactionsnum sharePricestring stockNamestring stockSymboloutput “Enter Stock Symbol…”input stockSymbolD.Design an application that declares an array of15StockTransactionobjects. Promptthe user for data for each object, and then pass the array to a method thatdetermines and displays the two stocks with the highest and lowest price per share.startDeclarations
num SIZE=10Stock Transaction stocks[10]num subsub =0while substocks[sub]=getDetails()sub=sub +1endwhileprintHighLowStocks(stocks,SIZE)stoppublic static StockTransction getDetails()DeclarationsStock Transactionsnum sharePricestring stockNamestring stockSymboloutput “Enter Stock Symbol…”input stockSymboloutput “Enter Stock Name..”input stockNameoutput “Enter per share price…”input sharePrices.setStockSymbol(stockSymbol)s.setStockName(stockName)s.setPricePerShare(sharePrice)return spublic static void printHighLowStocks(StockTransaction[]stocks, num SIZE)Declarationsnum ratenum minnum maxnum minRnum maxRnum subsub=1min=0max=0minR=stocks[0].getPricePerShare()maxR=stocks[0].getPricePerShare()while subrate=stocks[sub].getPerShareRate()if minR>rateminR=ratemin=subendif

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 16 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
N/A
Tags
Object Oriented Programming, Subroutine, public class StockTransaction, public void setStockSymbol

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture