我正在对5种产品进行模拟调查。目前正在为高中学习JavaFX。任务是从1到5生成1000个随机数,我必须在代表10票的小圆圈中为每个客户选择打印结果。
编辑:我想打印一个' O'每生成10张选票,但只得到一张O'即使有足够的生成数字。
//Rounding up the numbers that have been generated
int a = (int) Math.ceil(prodOne / 10.0);
int b = (int) Math.ceil(prodTwo / 10.0);
int c = (int) Math.ceil(prodThree / 10.0);
int d = (int) Math.ceil(prodFour / 10.0);
int e = (int) Math.ceil(prodFive / 10.0);
//for-loop to print one 'O' for every 10 votes
String s = "";
for (int i = 0; i < a; i++){
s += "O ";
}
lblProductOne.setText(s);
s="";
for (int i = 0; i < b; i++){
s += "O ";
}
lblProductTwo.setText(s);
s="";
for (int i = 0; i < c; i++){
s += "O ";
}
lblProductThree.setText(s);
s="";
for (int i = 0; i < d; i++){
s += "O ";
}
lblProductFour.setText(s);
s="";
for (int i = 0; i < e; i++){
s += "O ";
}
lblProductFive.setText(s);
}