1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lidiya [134]
3 years ago
6

Write a method called removeHighPrice that will go through a provided ArrayList called prices and removes the first price that i

s more than $5.00 and return the new ArrayList. If a price over $5 is not found, it returns the original ArrayList.
Computers and Technology
1 answer:
Diano4ka-milaya [45]3 years ago
6 0

Answer:

The method written in Java is as follows:

public static ArrayList<Double> removeHighPrice (ArrayList<Double> prices){

       for(int i =0;i<prices.size();i++){

     if(prices.get(i) > 5.00){

         prices.remove(i);  

         break;

     }

 }

 return(prices);  

 }

Explanation:

This line declares the method

public static ArrayList<Double> removeHighPrice (ArrayList<Double> prices){

This line iterates through the ArrayList named prices

       for(int i =0;i<prices.size();i++){

This checks if current price is greater than 5

     if(prices.get(i) > 5.00){

If yes, the price is removed

         prices.remove(i);  

And the loop is terminated

         break;

     }

 }

This returns the ArrayList

 return(prices);  

 }

<em>I've added as an attachment, the complete program which includes the main method</em>

Download txt
You might be interested in
How to unsubscribe from Brainly
solong [7]
Access the Settings app.
Tap your name.
Scroll down until you reach the Subscriptions feature.
Tap on Subscriptions.
Locate your Brainly Plus subscription.
Select Cancel Subscription.
Tap Confirm.
3 0
3 years ago
Read 2 more answers
Which of the following statements is false? a. A class can directly inherit from class Object. b. If the class you're inheriting
Dovator [93]

Answer: C

Explanation:

5 0
3 years ago
What connects two or more LANs together?
boyakko [2]
Wide Area Network also known as WAN
3 0
3 years ago
Read 2 more answers
The work day has just started and you receive reports that the inventory management server is not accessible on your company's n
drek231 [11]

Answer:

Option 3 i.e., Server manager is the correct option.

Explanation:

The server manager is the MS windows tool for the purpose to examine and maintain the function of the server and alter the configuration. So, when the user gets the reports of the management server of the inventory or stock which is not usable by the company's server of the following user. Then, he recalls the new admin of the server. The server manager tool should be used by the admin of the server.

7 0
3 years ago
What refrigerant has been approved for new household refrigerators and freezers
Alexxx [7]
Bsbsnsnsnsn jajwjemoeododhdhdw whajsjshtzzvsssnxbba. 3
8 0
3 years ago
Other questions:
  • What is the type of account and normal balance of allowance for uncollectible accounts?
    13·2 answers
  • You have an insurance policy with a $300 premium and a $500 deductible. How much should you expect to pay the insurance company
    15·1 answer
  • The left column values in a table array are called table ____
    13·1 answer
  • What will be the output of the following Python code? class A: def test1(self): print(" test of A called ") class B(A): def test
    15·1 answer
  • You listened to a song on your computer. Did you use hardware or software? Explain.
    11·2 answers
  • Write a Python program that reads the CSV file, compares the population estimates of every row for 2010 and 2017 and computes th
    10·1 answer
  • ________ is a computer-based network that triggers actions by sensing changes in the real or digital world.
    15·2 answers
  • In the code segment below, assume that the int variable n has been properly declared and initialized. The code segment is intend
    5·1 answer
  • I don’t understand this, i need help
    7·1 answer
  • Write a Coral program using integers userNum and x as input, and output userNum divided by x four times.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!