Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I am working on a computer science lab with many parts, however I am stuck on the 80 point part.... Here are instructions to

Hello, I am working on a computer science lab with many parts, however I am stuck on the 80 point part.... Here are instructions to the lab:

For each lab version, you MUST have a runner class called Runner and a class called ArrayLab. The method signatures shown below represent methods in the ArrayLab class.

***I have already done the 70 point part of the lab, but I need help with the 80 point part of the lab.

70 Point Lab

Ask the user how many numbers will be read in from the keyboard.

Use a loop and a Scanner class method to read int values from the keyboard and then put these values into an array.

Use the how many numbers value to end the loop.

If 3, 2, 5 and 5 were the numbers entered in that order, your code would print the following:

The numbers entered were: [3, 2, 5, 5] note: the Arrays class has a method that will format the list this way for you.

The minimum number in the list is 2. public static int minInList(int[] list) must be used and located in the ArrayLab class.

The maximum number in the list is 5. public static int maxInList(int[] list) must be used and located in the ArrayLab class.

The average of the values in the list is 3.75. public static double avgOfList(int[] list) must be used and located in the ArrayLab class.

80 Point Lab

Includes the requirements from the 70 Point Lab plus:

The value 6 was not in the list. public int valueInList(int[] list, int value) must be used and located in the ArrayLab class.

The value 5 is in spot 3 in the list. public int valueInList(int[] list, int value) must be used and located in the ArrayLab class.

Yes, both of these use the same method that returns an int value.

Here is my program so far:

import java.util.Scanner;

public class Runner {

public static void main (String args[]) {

Scanner input = new Scanner (System.in);

System.out.print("Enter how many numbers : " );

int size = input.nextInt();

int arr [] = new int [size] ;

System.out.println("Enter values : ");

for (int i=0; i

arr [i] =input.nextInt () ;

}

ArrayLab arrlab = new ArrayLab ();

System.out.println("The numbers entered were : " +arrlab.printList(arr)) ;

System.out.println("The minimum number in the list is " +arrlab.minInList(arr));

System.out.println("The maximum number in the list is " +arrlab.maxInList(arr));

System.out.println("The average of the values in the list is " +arrlab.avgOfList(arr));

input.close();

}

}

public class ArrayLab {

public static String printList(int[] list){

String res= "[" ;

for(int i=0; i

res+=list[i];

res+= ',' ;

}

res= res.substring(0, res.length()-1) + "]";

return res;

}

public static int minInList (int[] list)

{

int min=list[0];

for(int i=0; i

if(min>list[i])

min=list[i];

}

return min;

}

public static int maxInList(int[] list)

{

int max= list[0];

for(int i=0; i

if(max

max=list[i];

}

return max;

}

public static double avgOfList (int [] list) {

double sum=0;

for(int i=0; i

sum+=list[i];

return sum/list.length;

}

}

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

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

=+. Alliteration The Magic of Macy's tagline.

Answered: 1 week ago

Question

Prepare a short profile of Henry words worth Longfellow?

Answered: 1 week ago

Question

What is RAM as far as telecommunication is concerned?

Answered: 1 week ago

Question

Question 1: What is reproductive system? Question 2: What is Semen?

Answered: 1 week ago

Question

Describe the sources of long term financing.

Answered: 1 week ago

Question

Define and measure service productivity.

Answered: 1 week ago