Created
March 20, 2013 05:22
-
-
Save blackraccoon000/5202505 to your computer and use it in GitHub Desktop.
乱数生成100未満なら更に乱数生成加算、
合計値100を超えたら終了
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created with IntelliJ IDEA. | |
* User: Yutaka Fujii | |
* Date: 13/03/20 | |
* Time: 13:44 | |
*/ | |
import java.util.Random; | |
public class RandomNum { | |
public static void main(String args[]){ | |
// 乱数生成 | |
Random rNum = new Random(); | |
// 1-10まで生成 | |
int iNum = rNum.nextInt(10)+1; | |
System.out.print(iNum); | |
// System.out.print(iNum+":"+(iNum+iNum)); | |
for(;;){ | |
if(iNum <= 100) { | |
int addNum = rNum.nextInt(10)+1; | |
iNum = (iNum+addNum); | |
System.out.print("+"+addNum); | |
} | |
if(100 < iNum){ | |
break; | |
} | |
} | |
System.out.print("="+iNum); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment