I've written a basic dice program in Java which takes a number of faces then randomly selects a number within that boundary. Here is the code:
package com.georgegibson.diceroller;
import java.util.Random;
import java.util.Scanner;
public class DiceRoller
{
public static void main(String []args)
{
Random dice = new Random();
Scanner input = new Scanner(System.in);
int faces;
int result;
System.out.println("Dice Roller\n");
System.out.println("How many faces does the dice have?");
faces = input.nextInt();
result = dice.nextInt(faces) + 1;
System.out.println("\nThe dice rolled a " + result + ".");
}
}
Seen as I am pretty new to Java (I come from C/C++ land), I should think this can be improved, but how?
EDIT: I know I should have a different package name, but I am going to get that domain (georgegibson.com).