Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1 Step 1: Create a Java Project named Labl. Step 2: In that project, create two classes named Numbers and Numbers Test. Details of

image text in transcribed
image text in transcribed
image text in transcribed
Exercise 1 Step 1: Create a Java Project named Labl. Step 2: In that project, create two classes named Numbers and Numbers Test. Details of classes are as follows: Numbers class Instance variables: an integer array named numbers Constructor: constructor that receives one integer value named size and creates numbers array with that size Methods: 1. generateNumbers (): accepts nothing, returns nothing. Uses a for loop to fill the array with numbers starting from 0 till size-1. If size is 10, array should be filled in with 0, 1, ..., 9. 2.printNumbers (): accepts nothing, returns nothing. Uses a for loop to print elements in the array (See output) Numbers Test class public class Numbers Test { public static void main(String[] args) { Numbers ni - new Numbers (10); ni.generateNumbers(); System.out.println("Printing Numbers"); ni.print Numbers(); } ) Expected Output: Printing Numbers @ 1 2 3 4 5 6 7 8 9 Exercise 2 For this exercise, we are updating both of our classes. Numbers Class (update existing class) Instance variables: a two-dimensional integer array named squares Constructor: a constructor that receives two integers named row and col, and creates the two- dimensional array with sizes row and col Methods: 1. printIndices(): accepts nothing, returns nothing. This method has a nested for loop and prints the indices of each position. You should use the length property of arrays in loops. (See output). You are not permitted to create any other variables except loop- control variables. 2. generateSquares (): accepts nothing, returns nothing. Use nested loops and generates squares of numbers and store them as rows and columns. You should use the length property of arrays in loops. You are not permitted to create any other variables except loop-control variables. 3. printSquares (): accepts nothing, returns nothing. Use nested loop to print elements of squares in a pattern. You need to use formatted output like printf (See output). You should use the length property of arrays in loops. You are not permitted to create any other variables except loop-control variables. 4. printStars Pattern (): accepts nothing, returns nothing. Use nested loop and conditional statements to print stars in a pattern (See expected output...print stars and spaces as required). You should use the length property of arrays in loops. You are not permitted to create any other variables except height, except loop-control variables and Scanner object. Numbers Test class (DON'T change this class... use As-Is) public class Numbers Test { public static void main(String[] args) { Numbers n1 = new Numbers (10); n1.generateNumbers(); System.out.println("Printing Numbers"); n1.print Numbers(); Numbers n2 = new Numbers (10, 10); System.out.println(" Printing Positions"); n2.print Indices(); n2.generateSquares(); System.out.println(" Printing Squares in a pattern"); n2.printSquares(); System.out.println(" Printing stars in Pattern"); n2.printPattern(); } }

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

More Books

Students also viewed these Databases questions

Question

What is a P&ID? I am not satisfy give downvote

Answered: 1 week ago

Question

LO2 Identify components of workflow analysis.

Answered: 1 week ago