Advertisement
Sim0o0na

Untitled

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