Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Numerical Methods For Engineers

Authors: Steven C. Chapra, Raymond P. Canale

5th Edition

978-0071244299, 0071244298

More Books

Students also viewed these Algorithms questions

Question

Repeat Example 30.3, but for x = 1 cm.

Answered: 1 week ago