Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.Scanner;
- public class Program {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- Random rand = new Random();
- int price = 1000;
- int baharovPrevNum = rand.nextInt(51);
- System.out.println(baharovPrevNum);
- for (int i = 0; i < 10; i++) {
- String myChoise = scan.nextLine();
- int baharovNum = rand.nextInt(51);
- System.out.println(baharovNum);
- if (myChoise.equals("money")) {
- break;
- } else if (myChoise.equals("up") && baharovNum > baharovPrevNum) {
- price += 1000;
- baharovPrevNum = baharovNum;
- } else if (myChoise.equals("down") && baharovNum < baharovPrevNum) {
- price += 1000;
- baharovPrevNum = baharovNum;
- } else {
- price = 0;
- break;
- }
- }
- System.out.println("Price: " + price);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement