Notes
Notes - notes.io |
Name: John Kevin T. Bueza
*/
// Java program to demonstrate working
// of java.lang.Math.random() method
import java.lang.Math;
import java.util.Scanner;
class Main {
// driver code
public static void main(String args[])
{
// define the range
int max = 6;
int min = 1;
int range = max - min + 1;
int bet = 0;
int C1 = 0;
int C2 = 0;
int C3 = 0;
String choColor1 = " ";
String choColor2 = " ";
String choColor3 = " ";
Scanner cC = new Scanner(System.in); // Create a Scanner object
System.out.println("Enter your color choice1");
C1 = cC.nextInt();
System.out.println("Enter your color choice2");
C2 = cC.nextInt();
System.out.println("Enter your color choice3");
C3 = cC.nextInt();
System.out.println("---------------------------------");
System.out.println("Enter your color Enter your Bet");
bet = cC.nextInt();
System.out.println("---------------------------------");
// used Math.random method to randomize the number between 1 to 6
int rand1 = (int)(Math.random() * range) + min;
int rand2 = (int)(Math.random() * range) + min;
int rand3 = (int)(Math.random() * range) + min;
System.out.println("Choice 1: " + C1);
System.out.println("randomize Color: " + rand1);
System.out.println("Choice 1: " + C2);
System.out.println("randomize Color: " + rand2);
System.out.println("Choice 1: " + C3);
System.out.println("randomize Color: " + rand3);
System.out.println("---------------------------------");
if (bet >= 20) {
// Switch case for the random number 1
switch(rand1){
case 1:
System.out.println("red");
choColor1 = "red";
break;
case 2:
System.out.println("blue");
choColor1 = "blue";
break;
case 3:
System.out.println("green");
choColor1 = "green";
break;
case 4:
System.out.println("yellow");
choColor1 = "yellow";
break;
case 5:
System.out.println("white");
choColor1 = "white";
break;
case 6:
System.out.println("pink");
choColor1 = "pink";
break;
default:
System.out.println("none of the above");
}
if (rand1 == C1){
System.out.println("you won!, color value : " + C1 + ", " + bet + " X 2 = " + bet * 2);
}
else{
System.out.println("you lose!, color value : " + C1 + ", " + bet + " X 0 = " + bet * 0);
}
// Switch case for the random number 2
switch(rand2){
case 1:
System.out.println("red");
choColor2 = "red";
break;
case 2:
System.out.println("blue");
choColor2 = "blue";
break;
case 3:
System.out.println("green");
choColor2 = "green";
break;
case 4:
System.out.println("yellow");
choColor2 = "yellow";
break;
case 5:
System.out.println("white");
choColor2 = "white";
break;
case 6:
System.out.println("pink");
choColor2 = "pink";
break;
default:
System.out.println("none of the above");
}
if (rand2 == C2){
System.out.println("you won!, color value : " + C2 + ", " + bet + " X 2 = " + bet * 2);
}
else{
System.out.println("you lose!, color value : " + C2 + ", " + bet + " X 0 = " + bet * 0);
}
// Switch case for the random number 3
switch(rand3){
case 1:
System.out.println("red");
choColor3 = "red";
break;
case 2:
System.out.println("blue");
choColor3 = "blue";
break;
case 3:
System.out.println("green");
choColor3 = "green";
break;
case 4:
System.out.println("yellow");
choColor3 = "yellow";
break;
case 5:
System.out.println("white");
choColor3 = "white";
break;
case 6:
System.out.println("pink");
choColor3 = "pink";
break;
default:
System.out.println("none of the above");
}
if (rand3 == C3){
System.out.println("you won!, color value : " + C3 + ", " + bet + " X 2 = " + bet * 2);
}
else{
System.out.println("you lose!, color value : " + C3 + ", " + bet + " X 0 = " + bet * 0);
}
}
else{
System.out.println("The minimum bet is 20 PHP");
}
}
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team