lundi 29 février 2016

Generating Random Date

I'm a novice Java student. I have only been studying programming for a few months at school, and so I am currently pretty bad at it, and often feel stuck doing my assignments.

Anyway, I have a question regarding an assignment. I have been looking around and not quite finding the answers I need, so I was hoping to find some help on here. It would be much appreciated. My assignment goes like this: "Write a program that creates a Date object and a Random object. Use the Random object to set the elapsed time of the Date object in a loop to 10 long values between 0 and 100000000000 and display the random longs and the corresponding date and time."

We were just introduced to the classes java.util.Random and java.util.Date to work with this assignment, and are expected to use them to create the needed Date and Random objects.

The only things I really know how to do for this assignment are how to start the code:

import java.util.Date
import java.util.Random

public class RanDate {
public static void main(String[] args) {

And how to create the loop:

for (int i = 0; i <= 10; i++) {

I'm sorry if my question was too vague, or if I didn't ask something properly. This is my first time asking for help on this site. Thank you in advance for your help.




Aucun commentaire:

Enregistrer un commentaire