Advertisement
Guest User

Name war

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