Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with writing part 2 of this Java program? Put your name as a comment on the top of the class. Import the scanner

Please help with writing part 2 of this Java program?

  • Put your name as a comment on the top of the class.
  • Import the scanner package.
  • Write the name of the class, perhaps YOURNAME_Lab1.
  • Write the main method header (public static void main(String[] args)).
  • Inside main, create the scanner object using System.in as the parameter.
  • Ask the user to provide their name and age using the appropriate prompts, and scanner commands.
  • Then print the users name and age.

  1. Save the file if you havent already done so. Then compile the file and run it.

Part 2 Array Operations

For this part of the lab, you'll be writing methods to work with 1D arrays. We will expect you to know how to create an array, and store and retrieve information from them.

  1. Add a new java class to your existing folder.

  1. Put your name as a comment on the top of the class.

  1. You will be generating random numbers so import java.util.Random.
    • You should consider developing the methods for this project incrementally.

  1. In main, use an initializer list create an array of integers called nums holding the following values: 1, 4, 13, 43, -25, 17, 22, -37, 29.

  1. Write a method, called findLargest, that returns the largest value in the array and have the main print the result.

  1. Create an integer array of size 20, called data and write a method to fill the array with random integers from [-100, 100].
    • Recall that Randoms nextInt(x) method returns a value from 0 to x-1. The upper bound is exclusive, in other words. Modify the values to fit the required ranges.

  1. Use the findLargest method you previously wrote to return the largest value in data for the main to print.

  1. Print the sum of the largest values from nums and data.

Print the contents of data.

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

Introduction To Database And Knowledge Base Systems

Authors: S Krishna

1st Edition

9810206208, 978-9810206208

More Books

Students also viewed these Databases questions

Question

=+3. What are the organization's task goals on this issue?

Answered: 1 week ago