Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scan=new Scanner(System.in);
- Random rand = new Random();
- int num = 1+ rand.nextInt(100);
- while(true){
- int myNum =Integer.parseInt(scan.nextLine());
- if(num==myNum){
- break;
- }else if(num>myNum){
- System.out.println("UP");
- }else{
- System.out.println("DOWN");
- }
- }
- System.out.println("Bravo!");
- }
- }
- HOMEWORK
- import java.util.Random;
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scan=new Scanner(System.in);
- Random rand = new Random();
- int prize=0;
- int num1 = 1+ rand.nextInt(100);
- System.out.println(num1);
- int UpDown=scan.nextInt();
- while(UpDown==1){
- int num2 = 1+ rand.nextInt(100);
- System.out.println(num2);
- if(num2>num1){
- prize+=500;
- }
- if(num2<num1){
- break;
- }
- }
- while(UpDown==2){
- int num3 = 1+ rand.nextInt(100);
- System.out.println(num3);
- if(num3<num1){
- prize+=500;
- }
- if(num3>num1){
- break;
- }
- }
- System.out.println(prize);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement