Solved

# How to write a program using this statement, int n = (int)Math.floor(Math.random()*100000+1);?

Posted on 2011-03-24

Math

How to write a program using this statement, int n = (int)Math.floor(Math.random()*100000+1);?

lass GuessingGame {

public static void main(String[] args) {

int n = (int)Math.floor(Math.random()*100000+1);

int sum = 0;

int digit;

number = x;

digit = x % 10;

sum += digit;

x = x/10;

digit = x % 10;

sum += digit;

x = x/10;

digit = x % 10;

sum += digit;

x = x/10;

digit = x % 10;

sum += digit;

System.out.println("Given number= "+number+"; sum of digits = "+sum);

}

}