C design an application that declares an array of

This preview shows page 8 - 12 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
c. Design an application that declares an array of five CheckingAccountobjects. Prompt the user for data for each object, and then display all the values.
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-9x = x + 1endwhilex = 0while x < MAXaccounts[x].displayValues()x = x + 1endwhilestopCheckingAccount getAccountData()DeclarationsCheckingAccount accountstring namenum accoutnNumnum balanceoutput “Enter your name ”input nameoutput “Enter account number ”input numberoutput “Enter balance ”input balanceaccount.setName(name)account.setAccountNum(number)account.setBalance(balance)return accountd. Design an application that declares an array of five CheckingAccountobjects. Prompt the user for data for each object, and then pass the array to a method that determines the sum of the balances.Answer: A sample solution followsclass CheckingAccountDeclarationsprivate num accountNumprivate string nameprivate num balancepublic void setAccountNum(num number)accountNum = numberreturnpublic void setName(string name)this.name = namereturnpublic void setBalance(num bal)balance = balreturnpublic num getBalance()
Programming Logic and Design, 8eSolutions 10-10return balancepublic void displayValues()output “Account number: ”, accountNumoutput “Name: ”, nameoutput “Balance: ”, balancereturnendClassstartDeclarationsnum x = 0num sumnum MAX = 5CheckingAccount accounts[MAX]while x < MAXaccounts[x] = getAccountData()x = x + 1endwhilesum = getBalanceSum(accounts)output “The sum of all balances is: ”, sumstopCheckingAccount getAccountData()DeclarationsCheckingAccount accountstring namenum accoutnNumnum balanceoutput “Enter your name ”input nameoutput “Enter account number ”input numberoutput “Enter balance ”input balanceaccount.setName(name)account.setAccountNum(number)account.setBalance(balance)return accountnum getBalanceSum(CheckingAccount[] accounts)Declarationsnum sum = 0num x = 0num MAX = 5while x < MAXsum = sum + accounts[x].getBalance()x = x + 1endwhilereturn sum
Programming Logic and Design, 8eSolutions 10-116.Complete the following tasks: a. Design a class named StockTransactionthat holds a stock symbol (typically one to four characters), stock name, and price per share. Include methods to set and get the values for each data field. Create the class diagram and write the pseudocode that defines the class.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture