# Setstocknamename return trans void

• Homework Help
• 266
• 68% (22) 15 out of 22 people found this document helpful

This preview shows page 15 - 20 out of 266 pages.

trans.setStockName(name) trans.setPricePerShare(price) return trans void display(StockTransaction trans) output “Stock Transaction data” output “Stock symbol: ”, trans.getStockSymbol() output “Name: ”, trans.getStockName() output “Price: ”, trans.getPricePerShare() c. Design an application that declares an array of 10 StockTransaction s. Prompt the user f Answer: A sample solution follows
endwhile displayHighLowPrices(trans) stop StockTransaction getStockData() Declarations StockTransaction trans string stockSym string name num price output “Enter stock symbol ” input stockSym output “Enter stock name ” input name output “Enter price ” input price trans.setStockSymbol(stockSym) trans.setStockName(name) trans.setPricePerShare(price) return trans void displayHighLowPrices(StockTransaction[] transactions) Declarations num high = transactions[0].getPricePerShare() num low = transactions[0].getPricePerShare() num MAX = 10 d. Design an application that declares an array of 10 StockTransactionobjects. Prompt th Answer: A sample solution follows
7.Complete the following tasks:a. Design a class named Pizza. Data fields include a string field for a topping (such as peppero
b. Design an application that declares two Pizzaobjects and sets and displays their values.
start Declarations Pizza myPizza Pizza yourPizza myPizza.setTopping(“Extra Cheese”) myPizza.setDiameter(12) myPizza.setPrice(13.49) yourPizza.setTopping(“Meatball”) yourPizza.setDiameter(14) yourPizza.setPrice(15) output “Pizza 1 info:” output myPizza.getTopping() output myPizza.getDiameter() output myPizza.getPrice() output Pizza 2 info:” output yourPizza.getTopping() output yourPizza.getDiameter() output yourPizza.getPrice() stop Pseudocode: start Declarations num number string topping num size num price num x = 0 num MAX = 10 Pizza pizzas[MAX] while x > MAX output “Information for pizza ”, x+1 output “Enter the topping >>” input topping output “Enter the size >>” input size