Advertisement
Guest User

Game Name2

a guest
Oct 31st, 2019
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class new7 {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         String input = scan.nextLine();
  8.         int points = 0;
  9.         int points2 = 0;
  10.         String firstName = " ";
  11.         String secondName = " ";
  12.         int counter = 1;
  13.  
  14.         while (!input.equals("Stop")) {
  15.  
  16.             for (int i = 0; i < input.length(); i++) {
  17.                 int num = Integer.parseInt(scan.nextLine());
  18.                 if (num == input.charAt(i)) {
  19.                     if (counter % 2 != 0) {
  20.                         points += 10;
  21.                     } else if (counter % 2 == 0) {
  22.                         points2 += 10;
  23.                     }
  24.                 } else {
  25.                     if (counter % 2 != 0) {
  26.                         points += 2;
  27.                     } else if (counter % 2 == 0) {
  28.                         points2 += 2;
  29.                     }
  30.                     if (counter % 2 != 0) {
  31.                         firstName = input;
  32.                     } else if (counter % 2 == 0) {
  33.                         secondName = input;
  34.                     }
  35.                 }
  36.                
  37.             }
  38.             counter++;
  39.             input = scan.nextLine();
  40.  
  41.         }
  42.         if (points > points2) {
  43.             System.out.printf("The winner is %s with %d points!", firstName, points);
  44.         } else if (points < points2) {
  45.             System.out.printf("The winner is %s with %d points!", secondName, points2);
  46.         } else if (points == points2) {
  47.             System.out.printf("The winner is %s with %d points!", secondName, points2);
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement