Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Exercise {
- public static void main(String[] args) {
- Scanner scanner=new Scanner(System.in);
- boolean fair = false;
- System.out.println("Enter the number of classmates for class 1: ");
- int firstClass=scanner.nextInt();
- System.out.println("Enter the number of classmates for class 2: ");
- int secondClass=scanner.nextInt();
- System.out.println("Enter the number of classmates for class 3: ");
- int thirdClass=scanner.nextInt();
- System.out.println("How much money have the first class won: ");
- double moneyFisrtEarn=scanner.nextDouble();
- System.out.println("How much money have the second class won: ");
- double moneySecondEarn=scanner.nextDouble();
- System.out.println("How much money have the third class won: ");
- double moneyThirdEarn=scanner.nextDouble();
- System.out.println("How much cost the excursion: ");
- int moneyExcursion=scanner.nextInt();
- if(!fair) {
- if(moneyFisrtEarn>moneySecondEarn && moneySecondEarn>moneyThirdEarn) {
- fair=true;
- }else {
- System.out.println("This numbers are not fair. Think again!!!");
- fair=false;
- }
- }
- whoWon(firstClass,moneyFisrtEarn,moneyExcursion);
- whoWon(secondClass,moneySecondEarn,moneyExcursion);
- whoWon(thirdClass,moneyThirdEarn,moneyExcursion);
- }
- static void whoWon(int students,double moneyEa,double moneyEx) {
- int seats=(int) (moneyEa/moneyEx);
- int remainder=students-seats;
- int available=students-remainder;
- System.out.println("For the class there are: "+available+ " lucky students and "+ remainder+ " unlucky");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement