Menu

[solved]-Create Program Called Numberarrayjava Generate Appropriate Output Use Dbpm Template Botto Q39008747

Create a program called NumberArray.java that will generate theappropriate output .
USE THE DBPM TEMPLATE AT THE BOTTOM OF THE INSTRUCTIONS.

OUTPUT:
What size array would you like?: 3
Printing Single Diminsion Array Values
Array Value [0] = 200
Array Value [1] = 300
Array Value [2] = 400
Sum is 900
Average is 300
Printing Single Diminsion Array Values
Array Value [0] = 4
Array Value [1] = 17
Array Value [2] = 22
Array Value [3] = 8
Array Value [4] = 35
Sum is 86
Average is 17

DBPM FORMAT TEMPLATE

package numberarray;

import java.util.Scanner;

public class NumberArray
{
//declare a single diminsion array to store integers calledwholeNumbers

//create an overloaded constructors with the parameter intsize
{
this.wholeNumbers = /*initialize with an array of integers based onthe size parameter */
int initzValue = 100;
for (int x=0; x < this.wholeNumbers.length; x++)
this.wholeNumbers[x] = initzValue+=100;
}
//create an overloaded constructor with the parameter int []wholeNumbers
public NumberArray( int [] wholeNumbers) { this.wholeNumbers =/*initialize with the passed in parameter */ }

//create a setter for the attribute wholeNumbers

//create a getter for the attribute wholeNumbers

//created an overloaded method called showNumbers withoutparameters and a void return type
{
int total = 0;
System.out.println(“Printing Single Diminsion Array Values”);

for(int x = 0; x < /*create a for loop based on the length ofthe array wholeNumbers */ ; ++x){
System.out.println(“Array Value [” + x + “] = ” +wholeNumbers[x]);
total += wholeNumbers[x];
}
System.out.println(“Sum is ” + total);
System.out.println(“Average is ” + (total / wholeNumbers.length));
}
//created an overloaded method called showNumbers with a parameterof int [] arrayOfNumbers and a void return type
{
int tot = 0;
System.out.println(“Printing Single Diminsion Array Values”);
for(int x = 0; x < arrayOfNumbers.length; ++x){
System.out.println(“Array Value [” + x + “] = ” + /*display thearray element based on x */ );
tot += /*assign the array element based on x */
}
System.out.println(“Sum is ” + tot);
System.out.println(“Average is ” + (tot / arrayOfNumbers.length));
}
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print(“nWhat size array would you like?: “);
NumberArray inputNumbers = new NumberArray(input.nextInt());
inputNumbers.showNumbers(inputNumbers.getWholeNumbers());

// create an int array called someNums and initialize it to 4, 17,22, 8 and 35

NumberArray defaultNumbers = /*use the new operator and call theoverloaded constructor NumberArray, passing the array someNums*/

defaultNumbers.showNumbers();
}

}

Expert Answer


Answer to Create a program called NumberArray.java that will generate the appropriate output . USE THE DBPM TEMPLATE AT THE BOTTOM… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *