The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Write a program that generates 10 random integers between 0 and 100 and displays the count of the total number of single digit numbers. (Hint: Use an array of ten integers, say counts, to store the counts for single digit numbers. )
Â
Sample run:
Â
Random Array: 34 78 23 12 99 34 3 45 83 2
Â
Number of Single Digit Numbers: 2
Â
publicclassRandomNumbersArray {publicstaticvoidmain(String[]args) {//create integer array with the length of 10int[]numArray=newint[10];//give an initial value of i up to 10for(inti=0;i<10;i++)numArray[i] = (int)(Math.random()*100);//creates numbersbetween 0-100//display the numArrayfor(inti=0;i<10;i++){System.out.print(numArray[i] +" ");}System.out.println();//display the number of single digit numbersfor(inti= 0;i<10;i++){intj=numArray[i];if(j<10){System.out.print(numArray[i] +" ");}}}}
Attachments:
-----------