Advertisement
BetinaUKTC

3.2

May 31st, 2020
1,396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.42 KB | None | 0 0
  1. ЦЕНА ЗА ТРАНСПОРТ
  2. import java.util.Scanner;
  3. public class main {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         int km = Integer.parseInt(scan.nextLine());
  7.         String time = scan.nextLine();
  8.         double price = 0.0d;
  9.         double taxi = 0;
  10.         if (time.equals("day")) {
  11.             taxi =  0.79;
  12.         } else if (time.equals("night")) {
  13.             taxi = 0.90 ;
  14.         }
  15.         if (km < 20) {
  16.             price = 0.70 + (taxi * km);
  17.         } else if (km < 100) {
  18.             price = 0.09 * km;
  19.         }else{
  20.             price = km * 0.06;
  21.         }
  22.         System.out.println(price);
  23.     }
  24. }
  25. ТРЪБИ В БАСЕЙН
  26. import java.util.Scanner;
  27. public class main {
  28.     public static void main(String[] args) {
  29.         Scanner scan = new Scanner(System.in);
  30.         int v = Integer.parseInt(scan.nextLine());
  31.         int p1 = Integer.parseInt(scan.nextLine());
  32.         int p2 = Integer.parseInt(scan.nextLine());
  33.         double h = Double.parseDouble(scan.nextLine())
  34.         double water = p1 * h+p2 * h;
  35.         if (water <= v) {
  36.             System.out.printf(
  37.                     "The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.",
  38.                     Math.floor((water / v) * 100),
  39.                     Math.floor((p1 * h / water) * 100),
  40.                     Math.floor((p2 * h / water) * 100)
  41.             );
  42.         }else{
  43.             System.out.printf(
  44.                     ("For %.1f hours the pool overflows with %.1f liters."),
  45.                         h,water-v);
  46.         }
  47.     }
  48. }
  49. ПОСПАЛИВАТА КОТКА ТОМ
  50. import java.util.Scanner;
  51. public class main {
  52.     public static void main(String[] args) {
  53.         Scanner scan = new Scanner(System.in);
  54.         int daysOff = Integer.parseInt(scan.nextLine());
  55.         int workDays = 365 - daysOff;
  56.         int playTime = daysOff*127 + workDays*63;
  57.         int diff = Math.abs(30000 - playTime);
  58.         double hours = diff/60;
  59.         double minutes = diff%60;
  60.         if(playTime>30000){
  61.             System.out.println("Tom will run away");
  62.             System.out.printf( "%.0f hours and %.0f minutes more for play",hours,minutes);
  63.         }else{
  64.             System.out.println("Tom sleeps well");
  65.             System.out.printf( "%.0f hours and %.0f minutes less for play",hours,minutes); }
  66.     }
  67. }
  68. РЕКОЛТА
  69. import java.util.Scanner;
  70. public class main {
  71.     public static void main(String[] args) {
  72.         Scanner scan = new Scanner(System.in);
  73.         int areaGrapeField = Integer.parseInt(scan.nextLine());
  74.         double  graperPerSquareMeter = Double.parseDouble(scan.nextLine());
  75.         int wantedLitersWine = Integer.parseInt(scan.nextLine());
  76.         int workers = Integer.parseInt(scan.nextLine());
  77.         double  totalGrape = areaGrapeField * graperPerSquareMeter;
  78.         double wineLiters = (0.4 * totalGrape) / 2.5;
  79.         double difference = 0;
  80.         double litersPerWorker = 0;
  81.         if (wineLiters >= wantedLitersWine){
  82.             difference = wineLiters - wantedLitersWine;
  83.             litersPerWorker = Math.ceil(difference / workers);
  84.             System.out.printf(
  85.                     "Good harvest this year! Total wine: %.0f liters.%n",
  86.                     Math.floor( wineLiters));
  87.             System.out.printf(
  88.                     "%.0f liters left -> %.0f liters per person.",
  89.                     difference, litersPerWorker);
  90.         } else {
  91.             difference = Math.floor(wantedLitersWine - wineLiters);
  92.             System.out.printf(
  93.                     "It will be a tough winter! More %.0f liters wine needed.",
  94.                     difference);
  95.         }
  96.     }
  97. }
  98. ФИРМА
  99. import java.util.Scanner;
  100. public class Firm {
  101.     public static void main(String[] args) {
  102.         Scanner scanner = new Scanner(System.in);
  103.         int neededHours = Integer.parseInt(scanner.nextLine());
  104.         int days = Integer.parseInt(scanner.nextLine());
  105.         int workers = Integer.parseInt(scanner.nextLine());
  106.         double workDays = days * 0.9;
  107.         double workHours = workDays * workers * (8+2);
  108.         double hoursDif = Math.abs(neededHours - workHours);
  109.         if (workHours >= neededHours) {
  110.             System.out.printf("Yes!%.0f hours left.%n", Math.floor(hoursDif));
  111.         } else {
  112.             System.out.printf("Not enough time!%.0f hours needed.%n", Math.floor(hoursDif));
  113.         }
  114.     }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement