Advertisement
marking2112

Poll_Problem

Jun 17th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P24_Poll {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int people = Integer.parseInt(scanner.nextLine());
  8.         int firstPlace = Integer.parseInt(scanner.nextLine());
  9.  
  10.         double secPlace = firstPlace - (firstPlace * 0.2);
  11.         double thirdPlace = secPlace - (secPlace * 0.1);
  12.         double allThree = firstPlace + secPlace + thirdPlace;
  13.  
  14.         double halfVotes = people / 2;
  15.  
  16.         if (allThree >= halfVotes){
  17.             double diff = allThree - halfVotes;
  18.             double diff2 = (int) diff;
  19.             System.out.printf("First three languages have %.0f votes more", diff2);
  20.         }else {
  21.             double diff = halfVotes - allThree;
  22.             double diff2 = (int) diff;
  23.             System.out.printf("First three languages have %.0f votes less of half votes", diff2);
  24.         }
  25.  
  26.  
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement