Write a main class with a main method that tests your method

Assignment Help JAVA Programming
Reference no: EM131028324

Question 1. Write static methods as follows:

• double sum(double[] a) - returns the sum of the entries in the array a.

• double[] fill(int n, double v) - returns an array of n doubles, all of whose values are v.

• double[] random (int n) - return an array of n random doubles.

• double min(double[] a) - returns the minimum element of the array a.

• double max(double[] a) - returns the maximum element of the array a.

• double average(double[] a) - returns the average (or mean) of the elements of the array a.

• double variance(double[] a) - returns the variance of the elements of the array a (note: this method should call your average method).

• double stdDev(double[] a) - returns the standard deviation of the elements of the array a (note: this method should call your variance method).

• double[] read() - reads an array from the keyboard and returns it (read the number of elements first, and then that many numbers).

• void print(double[] a) - prints an array, a, on a single line with commas between elements (do NOT use Arrays.toString()).

Write a Main class with a main method that tests your methods appropriately (i.e. by calling each method at least once with various inputs), and printing the results.

Question 2. Consider the following method and method call:

public static int inc(int a) {

a++;

return a;

}

int a = 10;

int b = inc(a + 12);

int c = inc(a);

System.out.println(a);

System.out.println(b);

System.out.println(c);

What is the output from this code? Carefully explain your answer (i.e. carefully show how the method

inc is called).

Question 3. Consider the following method and method call:

public static int[] inc(int[] a) {

a[0]++;

return a;

}

int[] a = { 10, 20, 30, 40 };

int[] b = inc(a);

System.out.println(b[0]);

System.out.println(a[0]);

What is the output from this code? Carefully explain your answer (i.e. carefully show how the method

inc is called).

Question 4. Consider the following code:

int[] a = { 10, 20, 30, 40 };

int[] b = a;

int[] c = { 10, 20, 30, 40 };

System.out.println(a == b);

System.out.println(a == c);

What is the output from this code? Carefully explain your answer.

Reference no: EM131028324

Questions Cloud

How many choices are possible to find solution : If who selected which choice is ignored (as a chef would). Analyze this part by the number of different choices made.
Build an application based upon temperature converter app : e purpose of this assignment to confirm that sub routines and functions can be used within Visual Basic programs. Build an application based upon the Temperature Converter application demonstrated in this week's Presentation.
How is political independence embedded in role of fed chair : An article in the Wall Street Journal commented that despite Perry's remarks: " Bernanke is willing to embrace the political independence embedded in his role to do what Fed officials think the economy needs." How is "political independence" embed..
Constructor functions for your button events : constructor functions for your button events as outlined. This application simulates a vending machine that dispenses soft drinks.
Write a main class with a main method that tests your method : Write a Main class with a main method that tests your methods appropriately (i.e. by calling each method at least once with various inputs), and printing the results.
How the statistical devices can be used in business : How the following statistical devices can be used in business today? Describe their usefulness and how businessman can be benefit, or how to help them in making sound decisions. (Explain individually)
How many distinct ways can the assignments be made : Once all of the students have had their training, they will be assigned to 3 teams with 4 workers on each team and team duties will be assigned.
How many different orders can the song be arranged : A disk jockey can play 7 songs during his program. If there are 13 songs to chose from, in how many different orders can the song be arranged?
Statements for kohls corporation for the 2010 fiscal year : Financial statements for Kohl's Corporation for the 2010 fiscal year ending January 29, 2011. Under the term Groupings Filter, change the term All Forms to Annual Filings using the drop-down arrow and press Search.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd