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

Java , Create an object model for the Solar System using the following link...

Create an object model for the Solar System using the following link: Provide">http://airandspace.si.edu/etp/ss/index.htm Provide an abstract class called Planet and a concrete s

How the jms is different from rpc, In RPC the method invoker waits for the ...

In RPC the method invoker waits for the method to finish implementation and return the control back to the invoker. Therefore it is completely synchronous in nature. Whereas in JMS

Relation between stack and heap, Relation between Stack and Heap Stack ...

Relation between Stack and Heap Stack and heap are two significant memory areas. Primitives are created on the stack whereas objects are created on heap. This will be further c

Program for randomly generated 3- digit number matches, Program for Randoml...

Program for Randomly Generated 3- Digit Number Matches This assignment demonstrates your ability to use basic Java syntax including selection and looping statements. You will

Explain the both hashset and treeset, Explain the both HashSet and TreeSet?...

Explain the both HashSet and TreeSet? HashSet is an unordered, unsorted Set. It's a Collection set which restrict duplicate elements and also repositioning of elements. I

Java applet programming examples, Question: (a) The following is a simp...

Question: (a) The following is a simple example of a Java Class: // File: Welcome.java public class Welcome { public static void main(String args[]) { System.out.printl

Activity diagram, The statechart diagrams and activity diagram are related ...

The statechart diagrams and activity diagram are related in a sense that statechart diagram refers on object undergoing a transition process and an activity diagram refers on the f

I want prosport savings plans, I want ProSport Savings Plans Project Des...

I want ProSport Savings Plans Project Description: To prepare an application on iPhone, Mac, iPad and Android, which does the subsequent:- Provides a calculation of the am

Tasks with the classes Currency, In this assignment you work on a set of ta...

In this assignment you work on a set of tasks with the classes Currency, Money and Bank. Money and Currency You have been given a template for the Currency and Money classes (Lab1.

Create a program for student database, You are required to write a program ...

You are required to write a program that is going to be used to store the student details of a particular school.  This school caters for students aged between 5 years to 15 years.

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