0% found this document useful (0 votes)
387 views

Java Mini Project

This document describes a simple dice game program created in Java. The program generates random numbers between 1-6 to represent the dice roll for the player and computer. It uses switch statements to display the corresponding dice pattern and if statements to determine if the player or computer wins based on who rolls the higher number. The output shows the dice rolls and declares a winner or draw. The program demonstrates using random number generation and conditional statements to create a basic game.

Uploaded by

Shridhar Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
387 views

Java Mini Project

This document describes a simple dice game program created in Java. The program generates random numbers between 1-6 to represent the dice roll for the player and computer. It uses switch statements to display the corresponding dice pattern and if statements to determine if the player or computer wins based on who rolls the higher number. The output shows the dice rolls and declares a winner or draw. The program demonstrates using random number generation and conditional statements to create a basic game.

Uploaded by

Shridhar Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

welcome

JAVA Simple Dice Game


Roll no. Name

36 Shridhar suresh Patil

22 Prajwal Krushnat Sarnobat

16 Pravin Pralhad patil

Project Guide
Prof. Pranoti Tamgave mam

DEPARTMENT OF INFORMATION TECHNOLOGY


DR. J.J. MAGDUM COLLEGE OF ENGINEERING, JAYSINGPUR
Index:

1. Acknowledgement.
2. Introduction.
3. Program.
4. Output.
5. Information
6. Conclusion
ACKNOWLEDGEMENT
 

We find very happy in submitting project report


on “DICE GAME”. It is mostly impossible to
succeed alone. We are thankful for inspiration and
helpby our guide prof. Pranoti Tamgave mam.
(information Technology).he provided us valuable
advice and suggestions.
 
 

INTRODUCTION
 
Dice game are very much popular in the world and the board games of dice are also very much
popular. So here we created a simple Dice Game where you and Computer will have the battle
against you. In this program there is no need to put any input just run every time and get
output.
 
The program is made with “java.util.Random” for generating random number or picking up
random inputs from the program
. We are using Switch statement and IF statement in the program.
 
The result or output is very easy to understand there will be win, lose and draw. The output
will show the Dice value you got and the Dice value computer get and whose value is higher
will win the game and if equal then draw will be made.
Program:

import java.util.Random;
public class Program
{
public static void six(){
System.out.print("---------\n| * * |\n| * * |\n| * * |\n---------");
}
public static void five(){
System.out.print("---------\n| * * |\n| * |\n| * * |\n---------");
}
public static void four(){
System.out.print("---------\n| * * |\n| |\n| * * |\n---------");
}
}
public static void three(){
System.out.print("---------\n| * |\n| * |\n| * |\n---------");
}
public static void two(){
System.out.print("---------\n| * |\n| |\n| * |\n---------");
}
public static void one(){
System.out.print("---------\n| |\n| * |\n| |\n---------");
}
public static int random(){
Random r = new Random();
int a = r.nextInt(6)+1;
return a;
}
public static void main(String[] args) {
int you = random();
int computer = random();
System.out.println("you");
switch(you){
case 1: one(); break;
case 2: two(); break;
case 3: three(); break;
case 4: four(); break;
case 5: five(); break;
case 6: six(); break;
}
System.out.println("\n");
System.out.println("computer");
switch(computer){
case 1: one(); break;
case 2: two(); break;
case 3: three(); break;
case 4: four(); break;
case 5: five(); break;
case 6: six(); break;
}
if(you>computer){
System.out.println("\nLucky! you won. \n :)");
}
if(computer>you){
System.out.println("\nYou lost :( \n :)");
}
if(you==computer){
System.out.println("\nDraw! click run button again");
}
}
}
Output:
INFORMATION

• Here we are building a simple and fun dice game through java.
• We are using “java.util.random” class to generate random numbers.
• We created a dice pattern and the Dice value as well.
• We will using “switch statement” and “if statement” in the program.
• There is no need to input some value, just run and play the game.
Conclusion:
• We successfully created a simple dice game using java.
• Learned to use switch statement and If statement.

THANK YOU!

You might also like