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

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
Posted Date: 11/20/2012 9:06:20 PM | Location : United States







Related Discussions:- Need the following code for double variables instead of int, Assignment Help, Ask Question on Need the following code for double variables instead of int, Get Answer, Expert's Help, Need the following code for double variables instead of int Discussions

Write discussion on Need the following code for double variables instead of int
Your posts are moderated
Related Questions
Describe the Superclass in Inheritance ? In this example you start through defining a more common MotorVehicle class. public class MotorVehicle { private String licensePlat

writing a program to find common friends with the use of array

Write down HTML or JavaScript code for the following requirements: Declare an Array along with the identifier SUBJECT having length 5. Assign subsequent values to the array par

The more complicated the underlying system, the more critical the inter communication among everyone involved in deploying and developing the software. UML is a software language f

Hi i need help creating a small program that basically asks the user how many numbers hes going to use and then ask for those numbers and see which is the biggest and the smaller

Video course on computer security needed Project Description: We want a video course on computer security. Just like the way lynda provides. Skills required are Computer S

Project Description: We prepare and operate smartphone application.(Picture sharing and social networking) But there are problems in server side. It's very slow. So we

Project Description: Overview I am seeking an Oracle ADF mobile app and web service to be created that takes a list of contacts stored on an Android mobile phone or tablet an

I send you these files in order to make clear image about my task that I want you to design for me an application for PC that used to control robot arm via micro controller PIC18.

What is a multicast delegate? Every delegate object holds reference to a single method. Though, it is possible for a delegate object to hold references of and invoke multiple m