In java pls Using a text editor, create the file Homework6.scala with the follow
ID: 3711500 • Letter: I
Question
In java pls
Using a text editor, create the file Homework6.scala with the following contents: object Homework6 { def main (args:List[String]) println(value of x.:") println (x) write the following list-processing functions. Place these functions in the above HomeworkS·Print all the test cases in the main method as you did for the value of x. Upload the single Homework6.scala file in Dropbox Write a function called sum Triple that takes a List [Int] and produces an Int. The produced value should be triple the sum of the list of integers 1.Explanation / Answer
Test.java
import java.util.ArrayList;
public class Test{
public static int sumTriple (ArrayList<Integer> list) {
int sum = 0;
for(int i: list) {
sum+=i;
}
return 3 * sum;
}
public static void main(String []args){
ArrayList<Integer> list = new ArrayList<Integer>();
list.add(3);
list.add(4);
list.add(5);
list.add(6);
System.out.println("The triple the sum of the list of integers: "+sumTriple(list));
}
}
Output:
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.