Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String player1 = scanner.nextLine(),
- player2 = scanner.nextLine(),
- command;
- int card1, card2, point1 = 0, point2 = 0;
- while (!(command = scanner.nextLine()).equals("End of game")) {
- card1 = Integer.parseInt(command);
- card2 = Integer.parseInt(scanner.nextLine());
- if (card1 > card2) {
- point1 += card1 - card2;
- } else if (card1 < card2) {
- point2 += card2 - card1;
- } else {
- card1 = Integer.parseInt(scanner.nextLine());
- card2 = Integer.parseInt(scanner.nextLine());
- System.out.println("Number wars!");
- if (card1 > card2) {
- System.out.println(player1 + " is winner with " + point1 + " points");
- } else {
- System.out.println(player2 + " is winner with " + point2 + " points");
- }
- break;
- }
- }
- if (command.equals("End of game")) {
- System.out.println(player1 + " has " + point1 + " points\n" + player2 + " has " + point2 + " points");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement