Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Solve this program using the terms and references in the program. import java.util.ArrayList; // ======================================================================================== // ====== This runner class contains the main method to
Solve this program using the terms and references in the program. import java.util.ArrayList; // ======================================================================================== // ====== This runner class contains the main method to actually run the program ======== // ======================================================================================== public class Ch85_ArrayList_IntegerObjects_STU8a // Runner class { public static void main(String args) // ---- BEGIN JAVA PROGRAM ---- { int numNums = 50; // choose how many numbers to create int numPctNeg = 50; // target % neg numbers to have (00-100) //# int numsPerLine = 10; // how many numbers to print per line //# SOURCE OF: warning: [unchecked] unchecked conversion //# Because ArrayList was created in a class's method, and returned as reference (warnings are OK!) //# Java 'thinks' (correctly) it *could* cause an error in *other* circumstances, such as using //# Double instead of Integer in the called method createArrayListOfIntegers() ArrayList numbers = Tom.createArrayListOfIntegers(numNums,numPctNeg); //# Tom.printArrayList(numbers,numsPerLine); // print 1-D array in chosen format (# per line) System.out.println("\n\nSum of "+numNums+" numbers using Normal 'for' Loop: " +Tom.sumArrayList(numbers)); // sum with normal for loop System.out.println("Sum of "+numNums+" numbers using Enhanced 'for' Loop: " +Tom.sumArrayListEnhancedForLoop(numbers)); // sum with enhanced for loop! System.out.println("\n"+numPctNeg+"% DESIRED Neg Numbers"); System.out.println(Tom.pctNegNumbers(numbers)+"% ACTUAL Neg Numbers"); } // ---- END JAVA PROGRAM ---- } //
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started