please help with this homework, thanks !!
5)adding integrs to arrraylist.
ArrayList<Integer> list = new ArrayList<>(); list.add(1001); list.add(1100); list.add(1110);
//create the list with the ArrayList and add the elements.
6)To display the size of ArrayList
int count = list.size(); System.out.println("Count: " + count);
//list.size() ->used to find the arraylist size.
7)using for loop to cycle through the elements
ArrayList<Double> list = new ArrayList<>();
for (Double grades : list) { System.out.println(grades); }
8)find average:
float avg= average(list) // call method average with parameter Integer ArrayList list
System.out.println("Average: "+avg);
//average function. compute the average and return the value.
public float average(ArrayList<Integer> list) {
int total=0;
float avg=0;
for (int elem : list) {
total+=elem;
}
avg=(float)total / list.size();
return avg;
}
//any clarification please do comments
please help with this homework, thanks !! NAME CSC 236- ArrayList and Generics coding quz Write...
Please help. I need a very simple code. For a CS 1 class. Write a program in Java and run it in BlueJ according to the following specifications: The program reads a text file with student records (first name, last name and grade). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "printall" - prints all student records (first name, last name, grade). "firstname name" - prints all students with...
The following are screen grabs of the provided files Thanks so much for your help, and have a nice day! My Java Programming Teacher Gave me this for practice before the exam, butI can't get it to work, and I need a working version to discuss with my teacher ASAP, and I would like to sleep at some point before the exam. Please Help TEST QUESTION 5: Tamagotchi For this question, you will write a number of classes that you...