Im writing this in netbeans. Here is the code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package accounttoolssilverberg;
/**
*
* @author Administrator
*/
public class accountToolsSilverberg {
double a[];
int i;
public accountToolsSilverberg() {
a = new double[1000];
for (i = 0; i < 1000; i++) {
a[i] = Math.random() * 1000000;
}
}
public double[] getArray() {
return a;
}
public double myMax() {
double max = 0;
for (i = 0; i < 1000; i++) {
if (max < a[i]) {
max = a[i];
}
}
return max;
}
public double myMin() {
double min = 0;
for (i = 0; i < 1000; i++) {
if (min > a[i]) {
min = a[i];
}
}
return min;
}
public double myAVG(){
double sum = 0;
for (i = 0; i < 1000; i++){
sum = sum + a[i];
}
double avg;
avg = sum/1000;
return avg;
}
}
public class accountTooltestsilverberg {
public static void main(String[] args) {
accountToolsSilverberg test = new accountToolsSilverberg();
test.getArray();
System.out.println("Maximum account balance: $"+test.myMax());
System.out.println("Minimum account balance: $"+test.myMin());
System.out.println("Average account balance: $"+test.myAVG());
}
}
It is a program getting account balances from random numbers and showing max min and average. I need to know how to make the output display in dollar amount for example: 452323.00, and not 3344312.092389.
Also, I don't think that minimum calculation for that is correct.