EmiliaKitkarska

YearProject

Jun 10th, 2020
86
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 2.2 – Зеленчукова борса
  2. import java.util.Scanner;
  3. class Main {
  4.   public static void main(String[] args) {
  5.     Scanner scan = new Scanner(System.in);
  6.  
  7.       double vegP = scan.nextDouble();
  8.       double fruitP = scan.nextDouble();
  9.       int vegK = scan.nextInt();
  10.       int fruitK = scan.nextInt();
  11.      
  12.       double allFruit = fruitP*fruitK;
  13.       double allVeg = vegP*vegK;
  14.      
  15.    
  16.  
  17.  
  18.       System.out.println((allFruit + allVeg)/1.94);
  19.  
  20.    
  21.   }
  22. }
  23.  
  24. 3.2 – Поспаливата котка Том
  25. import java.util.Scanner;
  26. class Main {
  27.   public static void main(String[] args) {
  28.     Scanner scanner = new Scanner(System.in);
  29.     int holidays = scanner.nextInt();
  30.     int workingDays = 365 - holidays;
  31.     int totalPlayMinutes = workingDays * 63 + holidays * 127;
  32.     double difference = Math.abs(30000 - totalPlayMinutes);
  33.     double hours = difference / 60;
  34.     double minutes = difference % 60;
  35.  
  36.     if (totalPlayMinutes > 30000){
  37.       System.out.println("Tom will run away");
  38.       System.out.printf("%.0f hours and %.0f  minutes more to play",
  39.               Math.floor(hours), Math.floor(minutes));
  40.  
  41.     }else{
  42.       System.out.println("Tom sleeps well");
  43.       System.out.printf("%.0f hours and %.0f minutes less to play",
  44.              Math.floor(hours), Math.floor(minutes));
  45.     }
  46.   }
  47. }
  48.  
  49.  4.2 – Пътешествие
  50. import java.util.Scanner;
  51. class Main {
  52.   public static void main(String[] args) {
  53.     Scanner s = new Scanner(System.in);
  54.  
  55.     int budget =  Integer.parseInt(s.nextLine());
  56.     String season = s.nextLine();
  57.     double holiday = 0;
  58.  
  59.     if(budget<=100){
  60.     System.out.println("Somewhere in Bulgaria");
  61.       if(season.equals("summer")){
  62.       holiday = budget*0.3;
  63.       System.out.println(holiday);
  64.       }else if(season.equals("winter")){
  65.         holiday = budget*0.7;
  66.         System.out.println(holiday);
  67.       }
  68.     }
  69.     if(budget>100 && budget<=1000){
  70.     System.out.println("Somewhere in Balkans");
  71.     if(season.equals("summer")){
  72.       holiday = budget*0.4;
  73.       System.out.println(holiday);
  74.       }else if(season.equals("winter")){
  75.         holiday = budget*0.8;
  76.         System.out.println (holiday);
  77.       }
  78.   }
  79.   if(budget>1000 ){
  80.     System.out.println("Somewhere in Europe");
  81.     if(season.equals("summer")){
  82.       holiday = budget*0.9;
  83.       System.out.println(holiday);
  84.       }else if(season.equals("winter")){
  85.         holiday = budget*0.9;
  86.         System.out.println(holiday);
  87.       }
  88.   }
  89.   }
  90. }
  91.  
  92. 5.2 – умната Лили
  93. import java.util.Scanner;
  94. class Main {
  95.   public static void main(String[] args) {
  96.     Scanner scan = new Scanner(System.in);
  97.  
  98.     int age = scan.nextInt();
  99.     double priceP = scan.nextDouble();
  100.     double priceToy = scan.nextDouble();
  101.  
  102.     double birthdayMoney = 0;
  103.     double toyMoney = 0;
  104.     double money = 10;
  105.  
  106.     for(int i=1; i<=age; i++){
  107.       if(i%2==0){
  108.         birthdayMoney += money - 1;
  109.         money += 10;
  110.       }else{
  111.         toyMoney += priceToy;
  112.       }
  113.     }
  114.  
  115.     double allMoney = birthdayMoney + toyMoney;
  116.     if(allMoney > priceP){
  117.       System.out.println("Yes!");
  118.       double diff = allMoney - priceP;
  119.       System.out.printf("%.2f", diff);
  120.     } else{
  121.       System.out.println("No!");
  122.       double diff = priceP - allMoney;
  123.       System.out.printf("%.2f", diff);
  124.     }
  125.   }
  126. }
RAW Paste Data