Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class new7 {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String input = scan.nextLine();
- int points = 0;
- int points2 = 0;
- String firstName = " ";
- String secondName = " ";
- int counter = 1;
- while (!input.equals("Stop")) {
- for (int i = 0; i < input.length(); i++) {
- int num = Integer.parseInt(scan.nextLine());
- if (num == input.charAt(i)) {
- if (counter % 2 != 0) {
- points += 10;
- } else if (counter % 2 == 0) {
- points2 += 10;
- }
- } else {
- if (counter % 2 != 0) {
- points += 2;
- } else if (counter % 2 == 0) {
- points2 += 2;
- }
- if (counter % 2 != 0) {
- firstName = input;
- } else if (counter % 2 == 0) {
- secondName = input;
- }
- }
- }
- counter++;
- input = scan.nextLine();
- }
- if (points > points2) {
- System.out.printf("The winner is %s with %d points!", firstName, points);
- } else if (points < points2) {
- System.out.printf("The winner is %s with %d points!", secondName, points2);
- } else if (points == points2) {
- System.out.printf("The winner is %s with %d points!", secondName, points2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement