mercredi 19 août 2015

Use Math.random to display percentage number in Java

Currently coding simple program. I want to display percentage of each visit to the store in 52 weeks. For example "In 52 weeks store number 1 was inspected 20%". Here is the code so far.

public class StoreSelection {

public static void main(String[] args) {

    for( int i = 1; i<=52;i++){
        int randomSelection = 1+(int)(Math.random()*4);
 System.out.println(i+" week"+" Store number "+randomSelection+"   will be inspected");
    }
// here should be stated "In 52 weeks store number 1 was visited (number of percentage)
// and then below "In 52 weeks store number 2 was visited (number of percentage)  
   and same for number 3 and 4.

}

}




Aucun commentaire:

Enregistrer un commentaire