teddy-popova

Домашно 3.2

Oct 25th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.94 KB | None | 0 0
  1. Цена за транспорт:
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main
  6. {
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.         String DayOrNight = scan.nextLine();
  10.         int n = scan.nextInt();
  11.         if (n >= 100){
  12.           System.out.println(n*0.06);
  13.         } else if(n >= 20){
  14.           System.out.println(n*0.09);
  15.         }else {
  16.             if(DayOrNight.equals("Day")){
  17.                 System.out.println(0.7 + n*0.79);
  18.             }else if(DayOrNight.equals("Night")){
  19.                 System.out.println(0.7 + n*0.9);
  20.             }
  21.         }
  22.     }
  23. }
  24.  
  25.  
  26.  
  27. Тръби в басейн:
  28.  
  29.  
  30. public class Main
  31. {
  32.     public static void main(String[] args) {
  33.       Scanner scan = new Scanner(System.in);
  34.       int v = scan.nextInt();
  35.       double pipe1 = scan.nextDouble();
  36.       double pipe2 = scan.nextDouble();
  37.       double hours = scan.nextDouble();
  38.       double water = ((pipe1*hours + pipe2*hours)/v)*100;
  39.      
  40.       if (water <= v){
  41.          System.out.printf("The pool is %.0f%% full, pipe1: %.0f%%, pipe2: %.0f%%", water, pipe1/(pipe1+pipe2)*100, pipe2/(pipe1+pipe2)*100);
  42.       }else {
  43.           System.out.printf("For %f hours the pool overflows with %f liters", hours,((pipe1 + pipe2)*hours)-v);
  44.          
  45.       }
  46.    
  47.     }
  48. }
  49.  
  50.  
  51.  
  52. Поспаливата котка Том:
  53.  
  54.  
  55. import java.util.Scanner;
  56.  
  57.  
  58. class Main {
  59.     public static void main(String[] args) {
  60.         Scanner scan = new Scanner(System.in);
  61.         int holidays = scan.nextInt();
  62.         int workDays = 365 - holidays;
  63.         int totalTime = workDays*63 + holidays*127;
  64.         double vreme = Math.abs(totalTime - 30000);
  65.         double hours = vreme/60;
  66.         double minutes = vreme%60;
  67.        
  68.         if (totalTime > 30000){
  69.             System.out.println("Tom will run away");
  70.             System.out.printf("%.0f hours and %.0f minutes more for play.", Math.floor(hours), Math.floor(minutes));
  71.         } else{
  72.             System.out.println("Tom will sleep well");
  73.             System.out.printf("%.0f hours and %.0f less minutes for play.", Math.floor(hours), Math.floor(minutes));
  74.         }
  75.     }
  76. }
Add Comment
Please, Sign In to add comment