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>
*
An Object-Oriented code or coding refers to a technique of programming that utilizes the identification of classes of objects that are closely tied to the functions with which they are related.
<h3>What is a Procedural Oriented Code?</h3>
This refers to a kind of programming language that utilizes a step-by-step method so as to break down a task into a set or a collection of factors or variables and routines or sub-routines using a set of instructions that are sequential.
Objects in programming refer to a type of abstract data that has a state and behavior. It is a specific instance of a class.
A class in programming is a templated definition of the techniques and variables of a certain type of object.
<h3>What are some of the principles and structures of coding?</h3>
There are 10 principles of coding. Some of them are:
- Keep it simple
- Separate concerns
- Document your Code etc.
Some of these principles can be used in normal day-to-day activity and even in business. item 1 for instance can be used during communication. Effective communication is more effective when it is kept very simple.
It is to be noted that the code referenced in the question is unavailable hence the general answer.
Learn more about Object-Oriented Code at:
brainly.com/question/4560494
Answer:
import random
randomlist = []
for i in range(0,20):
n = random.randint(-29,30)
if n < 0 :
n = 100
randomlist.append(n)
print(randomlist)
Explanation:
The random module is first imported as it takes care of random. Number generation.
An empty list called randomliay is created to hold the generated random integers.
Using a for loop, we specify the range of random numbers we want.
Inside the for loop ; we attach our generated random integer which will be in the range (-29 to 30) in a variable n
For each n value generated, if the value is less than 0( it is negative, since all the values are integers), replace the value with 100.