Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Assignment

Iterating a method over a collection of objects is a common task that you may complete unknowingly each day. Within a collection of similar things, you identify the characteristics that make the individual elements unique and treat them differently according to their classifications. For example, assume that you are at a store and want to pay for something in cash. The bills in your wallet or purse represent a collection of similar objects, differentiated by denomination. It would not be very helpful to treat all of the bills the same, even though they are made from the same paper and have the same dimensions-eight bills does not equate to eight dollars unless each is a one-dollar bill.

How would you calculate how much money you have to spend? Each denomination needs a different value assigned. You compute a running total until you have accounted for all of the bills. For the moment, assume you are uncomfortable carrying large bills, so your wallet or purse contains $1, $5, $10, or $20 bills. The following program represents a "pseudo code" solution to this exercise.

totalCash is a whole number that starts at zero

while (I still have bills left to account for)

if (current bill is $1)
add 1 to totalCash
if (current bill is $5)
add 5 to totalCash
if (current bill is $10)
add 10 to totalCash
if (current bill is $20)
add 20 to totalCash

if (totalCash > itemPrice)
I have enough money to buy the item.

else

I don't.

This is an example of an iterative method because it is repeated over and over for the entire collection.

Think of a way in which you apply an iterative method to a collection of similar objects in your day-to-day life. Be creative-in other words, identify a situation that does not involve money (either paper or coins). Think about the ways in which the items of your collection are alike, as well as the key ways in which they differ.

1. Briefly describes your collection and the elements that comprise it

2. Identifies the characteristic(s) that differentiate(s) the elements of the collection

3. Briefly describes the method you apply to that collection

4. Defines the method using pseudo code that contains at least two if methods.

Java, Programming

  • Category:- Java
  • Reference No.:- M92266957

Have any Question?


Related Questions in Java

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As