Advertisement
vencinachev

Untitled

Feb 4th, 2019
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class Program {
  6.    
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.         Random rand = new Random();
  10.         int price = 1000;
  11.         int baharovPrevNum = rand.nextInt(51);
  12.         System.out.println(baharovPrevNum);
  13.         for (int i = 0; i < 10; i++) {
  14.             String myChoise = scan.nextLine();
  15.             int baharovNum = rand.nextInt(51);
  16.             System.out.println(baharovNum);
  17.             if (myChoise.equals("money")) {
  18.                 break;
  19.             } else if (myChoise.equals("up") && baharovNum > baharovPrevNum) {
  20.                 price += 1000;
  21.                 baharovPrevNum = baharovNum;
  22.             } else if (myChoise.equals("down") && baharovNum < baharovPrevNum) {
  23.                 price += 1000;
  24.                 baharovPrevNum = baharovNum;
  25.             }  else {
  26.                 price = 0;
  27.                 break;
  28.             }
  29.         }
  30.         System.out.println("Price: " + price);
  31.     }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement