Need the following code for double variables instead of int, JAVA Programming

Assignment Help:
Need the following code in double var instead of integer.

import javax.swing.*;

public class arrayVar
{
public static void main (String[] args)
//This is our main method prompting the user for prices and calling the
//appropiate methods
{
int[] price = new int[5];

//fill the array

for (int p=0; p < 5; p++)
{//get our values

price [p] = Integer.parseInt(JOptionPane.showInputDialog(null, "Please enter a value: "));

}//end for

int sum = sumArray(price);//call the sumArray method
int ave = aveArray(price);//call the aveArray method
int high = highPrices(price);//call the highPrices method

JOptionPane.showMessageDialog(null, "The sum of these values are $" + sum + "\nThe average of these values is: $" + ave + "\nThe values higher than the average are: " + high);

}//end main


public static int sumArray(int[] price)
{//method will receive array and return the sum of its elements. no output.
int sum = price[0];
for (int s=0; s < 5; s++)
{
sum +=price[s];

}//end for

return sum;

}//end method

public static int aveArray(int[] price)
{//method willl reveive array and return the average of its elements. no output.
int ave = price[0];
for (int a=0; a < 5; a++)
{
ave = (ave + price[a])/price.length;

}//end for

return ave;

}//end method

public static int highPrices(int[] price)
{//method receives array and an average. prints out all elements with values
//greater than the average

int ave = price[0];
int high = price[0];

for (int a=0; a < 5; a++)
{
ave = ave + price[a]/price.length;

}//end for

if (int h=0; h < 5 ; h++))
return true;
}//end method

}//end class

Related Discussions:- Need the following code for double variables instead of int

I want android expert, I want android expert Project Description: I h...

I want android expert Project Description: I have too many android project pending anyone who will start work right away, with me will bid here , only bid if you can work rig

List down the analytical engine''s elements name, List down the Analytical ...

List down the Analytical Engine's elements name An analytical engine elements are as follows: Input Memory Processor Output.

Virtual function, What is virtual function? While derived class override...

What is virtual function? While derived class overrides the base class method by redefining the same function, after that if client wants to access redefined the method from der

Describe even higer dimensions in java, Describe even higer dimensions in j...

Describe even higer dimensions in java? You don't have to stop along with two dimensional arrays. Java allows arrays of three, four or more dimensions. Therefore chances are pr

What restrictions are placed on method overriding, What restrictions are pl...

What restrictions are placed on method overriding? Overridden methods must have the similar name, argument list, and return type. The overriding method may not limit the access

Create a general design for a class-implement and test, Objectives 1.  ...

Objectives 1.      To design and implement a simple class. 2.      To write a test program to create instances of your class and demonstrate its behaviour. 3.      To col

Javascript to calculate the cost of each book, Write JavaScript code that i...

Write JavaScript code that is executed during form submission to calculate the cost of each book (based on quantity specified) and the overall total cost. The results should be dis

Write Your Message!

Captcha
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