Giter VIP home page Giter VIP logo

Comments (14)

AmritDuwal avatar AmritDuwal commented on July 30, 2024 1

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package bunkerarray;

import java.util.Random;

/**
*

  • @author Amrit Duwal
    */
    public class Randomnumberni {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      Random r = new Random();
      int x;
      System.out.println("Enter f6 to start the game");
      x = r.nextInt(10);
      System.out.print(x);
      if (x == 7) {

       System.out.println("\nyou won");
      

      } else {
      System.out.println("\ntry again enter(f6)");
      }

    }

}
random

from java.

milan604 avatar milan604 commented on July 30, 2024

package luckyseven;

import java.util.Random;

import javax.swing.JOptionPane;

/**
*

  • @author m-lan
    */
    public class LuckySeven {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      int x, y, z, count = 0;
      String key;
      while (true) {
      key = JOptionPane.showInputDialog("Enter G to generate (any key to exit)");
      if (key.equalsIgnoreCase("G")) {
      Random r = new Random();
      x = r.nextInt(10);
      if (x == 7) {
      count++;
      switch (count) {
      case 1:
      JOptionPane.showMessageDialog(null, "7\nYou are Lucky 7");
      break;
      case 2:

                       JOptionPane.showMessageDialog(null, "77\nYou are Super Lucky 7");
                       break;
                   case 3:
                       JOptionPane.showMessageDialog(null, "777\nYou are Awesome Lucky 7");
                       break;
                   default:
                       break;
               }
           } else {
               count--;
               if (count <= 0) {
                   count = 0;
               }
               JOptionPane.showMessageDialog(null, "Your Number is " + x + " Try Again...");
           }
      
       } else {
           break;
       }
      

      }

    }

}

screenshot from 2017-08-16 09-19-23
screenshot from 2017-08-16 12-28-16

screenshot from 2017-08-16 09-19-23

screenshot from 2017-08-16 09-20-00

from java.

Roshantwanabasu avatar Roshantwanabasu commented on July 30, 2024

Code:
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package luckyseven;

import java.util.Random;
import javax.swing.JOptionPane;

/**
*

  • @author NiiRosh
    */
    public class LuckySeven {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      Random r = new Random();
      String ch = "y";
      JOptionPane.showMessageDialog(null, "Welcome to Lucky 7 Game\nClick on ok to generate 7");
      while (ch.equalsIgnoreCase("y")) {
      int x = r.nextInt(10);

       if (x == 7) {
           JOptionPane.showMessageDialog(null, "Congratulation!!! You generated 7\nYou are lucky");
       } else {
           JOptionPane.showMessageDialog(null, "Sorry you generated:" + x + "\nBetter luck next time");
       }
       ch = JOptionPane.showInputDialog("Do you want to try your luck again??(y/n)");
      

      }
      }

}

Output:
welcome7
unluck7
try7
lucky

from java.

RakenShahi avatar RakenShahi commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package lucky.pkg7;

import java.util.Random;
import javax.swing.JOptionPane;

/**
*

  • @author DELL
    */
    public class Lucky7 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      int x, c = 0;
      String check = "y";
      Random r = new Random();

      JOptionPane.showMessageDialog(null, " LUCKY 7\n Welcome To The Game");
      JOptionPane.showMessageDialog(null, "Its Time to get to know your luck, Click on Ok to continue");
      while (check.equalsIgnoreCase("y")) {
      x = r.nextInt(10);
      JOptionPane.showMessageDialog(null, "You got number : " + x);
      if (x == 7) {
      c++;
      if (c >=2) {
      check = JOptionPane.showInputDialog("You are very lucky today\nWanna try again once more?\nYes : y\nNo : n");

           }
           check = JOptionPane.showInputDialog("Congratulation, you've got lucky number 7!\nYou have won the game\nAgain do you wish to try your luck?\nYes : y\nNo : n");
      
       } else {
           check = JOptionPane.showInputDialog("Sorry Bad luck!!!.\n Would you like to try again?(y/n)");
       }
      

      }

    }

}

}

OUTPUT
welcome
its
num 2
sory
luck7
againwish
luck7

vl

from java.

duwalshraddha avatar duwalshraddha commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package luckyseven;

import java.util.Random;
import javax.swing.JOptionPane;

/**
*

  • @author Lenovo
    */
    public class LuckySeven {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      String s = JOptionPane.showInputDialog("Do you wanna know if you are lucky? Enter y or n"), ch = "y";
      while (ch.equalsIgnoreCase("y")) {
      Random r = new Random();
      int x;
      x = r.nextInt(10);
      if (x == 7) {
      System.out.println("Wow!! you are lucky...you got 7");
      } else {
      System.out.println("Sorry the number generated is " + x);
      }
      ch = JOptionPane.showInputDialog("Do you wanna try again?\t\t (y/n)");
      }

    }

}
1
2
3
4

from java.

SusanCB avatar SusanCB commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package day13.pkg3;

import java.util.Random;
import javax.swing.JOptionPane;

/**
*

  • @author nissus
    */
    public class Day133 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      Random r=new Random();
      JOptionPane.showMessageDialog(null, " Welcome To Lucky7");
      JOptionPane.showMessageDialog(null, " Lets try your luck");
      JOptionPane.showMessageDialog(null, " Click OK to Generate the number");
      String ch="y";
      while (ch.equalsIgnoreCase("y")){
      int c=r.nextInt(10);
      if (c==7){
      JOptionPane.showMessageDialog(null, "7UP, you are lucky today");
      }
      else
      {JOptionPane.showMessageDialog(null, "Sorry, its"+c+" for you today");
      }
      ch= JOptionPane.showInputDialog(null, " Do you want to try again [Y/N]");
      }
      // TODO code application logic here
      }

}
13 1
13 2
13 3
13 4
13 5
13 6
13 7

from java.

raBbn avatar raBbn commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package lucky7;

import java.util.Random;
import javax.swing.JOptionPane;

/**
*

  • @author raBbn
    */
    public class Lucky7 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      int x, y, z, count = 0;
      String key;
      String ch="y";
      while (ch.equalsIgnoreCase("y")){
      JOptionPane.showMessageDialog(null,"play the game");
      Random r = new Random();
      x = r.nextInt(10);
      y = r.nextInt(10);
      z = r.nextInt(10);
      JOptionPane.showMessageDialog(null, x);
      JOptionPane.showMessageDialog(null, y);
      JOptionPane.showMessageDialog(null, z);
      if (x == 7 || y == 7 || z == 7) {
      JOptionPane.showMessageDialog(null,"you are lucky");
      }

      else if (x == 7 && y == 7 && z == 7) {
      JOptionPane.showMessageDialog(null,"you are very lucky");
      }

      else{
      JOptionPane.showMessageDialog(null,"you are out of luck ..SORRY");
      }

      ch=JOptionPane.showInputDialog("do you want to play again(y/n)??");
      }
      }
      }
      capture
      capture1
      capture2
      capture3
      capture4
      capture5

from java.

jagdish4249 avatar jagdish4249 commented on July 30, 2024

package pkg40lucky7;

import java.util.Random;
import javax.swing.JOptionPane;

/**
*

  • @author jagdish
    */
    public class Main {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      //String luckyNo = JOptionPane.showInputDialog("Press enter to check your luck");
      int Check;
      do{
      Random r = new Random();
      int x;
      x = r.nextInt(9); //nextInt(6)
      if(x==7)
      JOptionPane.showMessageDialog(null,"You are Mr. Lucky 7 Broda.");
      else
      JOptionPane.showMessageDialog(null,"Sorry. Luck is not with you this time.");

      Check = JOptionPane.showConfirmDialog(null,"Lets Check your Luck");
      }while(Check == 0);

    }

}

image

image

image

from java.

rabina12 avatar rabina12 commented on July 30, 2024

public class RandomNumber {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    // TODO code application logic here
    Random r = new Random();
    String ch = "y";
    JOptionPane.showMessageDialog(null, "Welcome");
    while (ch.equalsIgnoreCase("y")) {

        int x = r.nextInt(10);
        if (x != 7) {
            JOptionPane.showMessageDialog(null, "sorry!" + x + "\nbest of luck nexttime");
        } else {
            JOptionPane.showMessageDialog(null, "Congratulation");
        }
        ch = JOptionPane.showInputDialog("Do you want to try your luck again??(y/n)");

    }
}

}
c1
c2
c3
c4

from java.

sarumdr avatar sarumdr commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package lucky7;

import java.util.Random;
import javax.swing.JOptionPane;

/**
*

  • @author sarumdr
    */
    public class Lucky7 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      String s = "y";
      while (s.equalsIgnoreCase("y")
      {
      JOptionPane.showMessageDialog(null, "Welcome to Lucky 7 Game");
      JOptionPane.showMessageDialog(null, "lets check your luck");
      Random r = new Random()
      );
      int x = r.nextInt(100);
      if (x == 7) {
      JOptionPane.showMessageDialog(null, "Wow you got 7.\n Your luck is with you");
      } else if (x == 77) {
      JOptionPane.showMessageDialog(null, "superb you got" + x + ".\n super lucky");
      } else if (x == 777) {
      JOptionPane.showMessageDialog(null, "babaal you got" + x + ".\n you will have a great day today");
      } else {
      JOptionPane.showMessageDialog(null, "Oops you got" + x + ".\n May be luck is not with u today.");
      s = JOptionPane.showInputDialog("try again????");

       }
      

      }
      }
      }

}

OUTPUT
image

image

image

from java.

ajay987 avatar ajay987 commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package lucky7;

import java.util.Random;
import javax.swing.JOptionPane;

/**
*

  • @author Dell
    */
    public class Lucky7 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      Random r = new Random();
      int a = 7;
      String check = "y";
      while (check.equalsIgnoreCase("y")) {
      if (a == r.nextInt(10)) {

           JOptionPane.showMessageDialog(null, "lucky");
       } else {
           JOptionPane.showMessageDialog(null, "notlucky");
       }
       String check1 = JOptionPane.showInputDialog("want to continue?y/n");
       check = check1;
      

      }
      }

}
lu1
lu2
lu3

from java.

 avatar commented on July 30, 2024

package randomnumbergeneration;

import java.util.Random;
import java.util.Scanner;

/**
*

  • @author User
    */
    public class RandomNumberGeneration {

    private static int r1;

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      Scanner in = new Scanner(System.in);
      String check = "y";
      while (check.equalsIgnoreCase("y")) {
      System.out.println("Generating random number from 1 to 9...");
      randomm();
      if (r1 == 7) {
      System.out.println("Congratulations!!! You Win");
      } else {
      System.out.println("Sorry! You Lose!!!");
      }
      System.out.println("Would you like to try again? Y/N");
      check = in.next();
      }
      }

    public static void randomm() {
    Random r = new Random();
    r1 = r.nextInt(10);
    System.out.println("The number you got is:" + r1);
    if (r1 == 0) {
    randomm();
    }
    }
    }
    OUTPUT:
    luckylucky7

from java.

rituratnam avatar rituratnam commented on July 30, 2024

CODE:
package lucky7diag;

import static java.lang.Integer.parseInt;
import static java.time.Clock.system;
import java.util.Random;
import javax.swing.JOptionPane;

/**
*

  • @author User
    */
    public class Lucky7Diag {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {

      int name;
      String check = "y";
      Random r = new Random();
      int rnd = r.nextInt(7);
      while (check.equalsIgnoreCase("y")){
      name = parseInt(JOptionPane.showInputDialog("Enter a number between 1 and 7 "));
      JOptionPane.showMessageDialog(null, "The number you entered is " + name + "\nThe number generated by computer is " + rnd);
      if( name == rnd ){

       JOptionPane.showMessageDialog(null, "Congratulations !!" + "\nYou are so lucky");
      

      }

    else
    {
    JOptionPane.showMessageDialog(null, "Oops !!" + "\nBetter luck next time");
    check = JOptionPane.showInputDialog("Do you want to continue? \nYes : y\nNo : n");
    }
    }

    }
    }
    Output:
    p
    q
    r
    s
    t
    u
    v

from java.

Sudan15423 avatar Sudan15423 commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package magic7;

import static java.lang.Integer.parseInt;
import java.util.Random;
import javax.swing.JOptionPane;

/**
*

  • @author Dragon15423
    */
    public class Magic7 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      String ch = (JOptionPane.showInputDialog("Welcome !\nWant to test your luck?(yes/no)")), res = "";

      int[] result = {};
      result = new int[3];
      boolean test = true;
      if (ch.equalsIgnoreCase("yes")) {

       while (test == true) {
      
           Random r = new Random();
           for (int i = 0; i < result.length; i++) {
      
               result[i] = r.nextInt(10);
               res += result[i] + "";
               if (result[i] == 7) {
                   System.out.println("You sure are lucky (>.<)");
               } else {
                   switch (parseInt(res)) {
                       case 77:
                           System.out.println("You are super  lucky (>.<)");
                           break;
                       case 777:
                           System.out.println("Overkill (>.<)");
                           break;
                   }
      
               }
      
           }
           System.out.println("Your number=" + res);
      
           String ch1 = (JOptionPane.showInputDialog("Want to test your luck again?(yes/no)"));
           test = ch1.equalsIgnoreCase("yes");
           res = "";
       }
      

      }

    }

}
magic7
1
2

from java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.