これは私の要件です:
- ユーザーから整数を読み込む (n)
- サイズ n の浮動小数点数の配列を宣言する
- この配列に、0 から 100 までのランダムな浮動小数点数を入力します。
- 少なくとも 70 である配列内の値のパーセンテージを計算して表示します
最後の部分のやり方がわかりません。
import java.util.Random;
import java.util.Scanner;
/**
*
*
*/
public class Mo {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.print("please enter a number: ");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
float[] values;
values = new float[n];
int[] counters;
counters = new int[n];
Random r = new Random();
for(int i=0; i < values.length; i++)
{
values[i] = r.nextInt(100);
System.out.print(values[i] + " " );
}
System.out.println();
}
}