Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- import java.util.Scanner;
- public class AlonVsBenny {
- public static void main(String[] args)
- {
- Scanner in = new Scanner (System.in);
- char ch;
- int votesForAlon = 0, votesForBenny = 0;
- System.out.println("Enter the votes string:");
- for(ch = in.next().charAt(0); ch != '#'; ch = in.next().charAt(0))
- {
- switch(ch)
- {
- case 'A':
- votesForAlon++;
- break;
- case 'B':
- votesForBenny++;
- break;
- default:
- break;
- }
- }
- if(votesForAlon > votesForBenny)
- System.out.println("Alon won!");
- else
- System.out.println("Alon didn't win!");
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement