.java-Eclipse Window Help . ProblemSet Problemset Problemet. Problemset D Proble
ID: 3741055 • Letter: #
Question
.java-Eclipse Window Help . ProblemSet Problemset Problemet. Problemset D Probleset ProblemSet q1: Write a public static method named q1 that takes no paraneters and returns a nevw 6Arraylist of type Double containing the values 12.55, 4.8, 0.79, and 12.93. The order of these values must be maintained 13 14 " q2: Write a public static method named q2 that takes no parameters and returns a new Arraylist of type Double containing the values 5.31, 0.69, 4.09, and 4.42. The order of * these values must be maintained * q3: Write a public static method naned q3 that takes no paraneters and returns a new * HashMop with keys of type String mapped to values of type Integer containing the key-value * pairs ("hero":36, "blind :17, "awareness"-16, "mixture:7) 26 27 19 /* * g4: Write a public static method naned qt that takes an Arraylist of Integers as a * parameter and returns an int. The returned int should be the sum of the values in the input Arraylist at indices 17, 3, and 11, You can assuse the input Arraylist has size " Large enough to avoid an index out of bounds exception at these indices E Probiems lavadoc &Decla; ation Console Coverage No consoles to deplay at this tiemeExplanation / Answer
public class HelloWorld //Class name
{
public static void q1() //method name
{
double array[] = {12.55,4.8,0.79,12.93};
for(int i = 0; i<=array.length-1; i++ ) {
System.out.println(array[i]);
}
}
public static void main(String args[]) // Mail method is the starting point of java runtime
{
q1(); //method calling
}
}
output
12.55
4.8
0.79
12.93
wanted output
12.55
4.8
0.79
12.93
-----------------------------------------------------------------------------------------------------------------
public class HelloWorld //Class name
{
public static void q2() //method name
{
double array[] = {5.31,-0.69,4.09,-4.42};
for(int i = 0; i<=array.length-1; i++ ) {
System.out.println(array[i]);
}
}
public static void main(String args[]) // Mail method is the starting point of java runtime
{
q2(); //method calling
}
}
output
5.31
-0.69
4.09
-4.42
wanted output
5.31
-0.69
4.09
-4.42
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.