Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Introduction
Review
Exercise
Using and Writing Methods
CS401 Lab4
Huichao Xue
Department of Computer Science
University of Pittsburgh
Sep 29, 2008
Huichao Xue CS401 Lab4
Introduction
Review
Exercise
What’s covered in this lab
A Java program to roll the dice.(Not graded. . . )
A Quiz.
Huichao Xue CS401 Lab4
Introduction
Review
Exercise
Things that might be useful
Static Methods
Math class
Random Class1 in java.util
. . .
1http:
//java.sun.com/j2se/1.4.2/docs/api/java/util/Random.html
Huichao Xue CS401 Lab4
Introduction
Review
Exercise
What should be done
Write a Java program that will simulate rolling 2 six-sided dice,
and keep track of how many times each possible roll (2, 3, ...
12) occurs.
Details
Write a static void method called RollDice to:
1 Roll the dice
2 Count for each number
3 Print out the number of times each number comes up and
its fraction out of all of the rolls
In the main program, invoke RollDice.
See http://www.cs.pitt.edu/~ramirez/cs401/labs/
lab4.html for more information.
Huichao Xue CS401 Lab4