Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Poll {
  4.  
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. int participants = Integer.parseInt(scanner.nextLine());
  9. int votesForFirstPlace = Integer.parseInt(scanner.nextLine());
  10.  
  11. double votesForSecondPlace = votesForFirstPlace - (votesForFirstPlace / 5);
  12. double votesForThirdPlace = votesForSecondPlace -( votesForSecondPlace / 10);
  13.  
  14. double allVotes = votesForFirstPlace + votesForSecondPlace + votesForThirdPlace;
  15. double halfVotes = participants/2;
  16.  
  17.  
  18.  
  19.  
  20. if(allVotes >= halfVotes){
  21. double difference = Math.ceil(allVotes - halfVotes);
  22. System.out.printf("First three languages have %d votes more", ((int)difference));
  23.  
  24. }else {
  25. double difference = Math.ceil(allVotes - halfVotes);
  26. System.out.printf("First three languages have %d votes less of half votes", Math.abs((int)difference)) ;
  27. }
  28.  
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement