Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java random max and min

Random random = new Random();
int max = 10;
int min = 1;

int result = random.nextInt(max + 1 - min) + min;
Comment

maximum number from random number in java

Scanner s = new Scanner(System.in);
System.out.println("Type a number");
int n = s.nextInt();
int start = 0;
int largest = 0;
int occurrence = 0;

while(n > start){
    int number = (int)(Math.random()*100);
    if(number > largest){
        largest = number;


    }
    n--;
    System.out.print(number+" ");
}

System.out.println("max is "+largest);
System.out.println("Occurrence is "+occurrence);
Comment

maximum number from random number in java

Scanner s = new Scanner(System.in);
System.out.println("Type a number");
int n = s.nextInt();
int start = 0;
int largest = 0;
int occurrence = 0;

while(n > start){
    int number = (int)(Math.random()*100);
    if(number > largest){
        largest = number;


    }
    n--;
    System.out.print(number+" ");
}

System.out.println("max is "+largest);
System.out.println("Occurrence is "+occurrence);
Comment

PREVIOUS NEXT
Code Example
Java :: remove selected text from string value android java 
Java :: JFrame change outline 
Java :: java border 
Java :: how to recognize a pressed key in java 
Java :: if not java 
Java :: enable cors on apache tomcat 
Java :: java add element to map 
Java :: python discord embed generator 
Java :: random int between two values 
Java :: Printing cube root of a number in java 
Java :: android alert change color 
Java :: array copy java 
Java :: what is object in java 
Java :: java create array 
Java :: find out duplicate number between 1 to n numbers in java 
Java :: click on recyclerview item android animation 
Java :: How do I make my Android app scrollable? 
Java :: 1 elemenet array java 
Java :: java developer interview questions 
Java :: how to create textview in java android 
Java :: java string replaceall for space 
Java :: remove duplicates from arraylist in android 
Java :: arrays vs collections 
Java :: Java Expression statements 
Java :: finalize method 
Java :: adding watermark to excel 
Java :: insert node at end of doubly linked list 
Java :: configure JWT on Springboot 
Java :: instanceof java 
Java :: kafkalistener annotation pass topic from properties file 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =