SHARE
TWEET

4.2

BetinaUKTC May 31st, 2020 (edited) 1,029 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. НАВРЕМЕ ЗА ИЗПИТ
  2. import java.util.Scanner;
  3. public class main {
  4.     static void findStatus(int diff) {
  5.         String status = "";
  6.         if (diff < -30) {
  7.             status = "Early";
  8.         } else if (diff <=0) {
  9.             status = "On time";
  10.         } else if (diff > 0) {
  11.             status = "Late";
  12.         }
  13.         System.out.println(status);
  14.     }
  15.     static void difference(int diff) {
  16.         int hourDiff = Math.abs(diff / 60);
  17.         int minDiff = Math.abs(diff % 60);
  18.         if (diff != 0) {
  19.             if(hourDiff > 0){
  20.                 System.out.printf("%d:%02d hours",hourDiff,minDiff);
  21.             }else{
  22.                 System.out.printf("%2d minutes",minDiff);
  23.             }
  24.             if (diff>0){
  25.                 System.out.print(" after the start");
  26.             }else{
  27.                 System.out.print(" before the start");
  28.             }
  29.         }
  30.     }
  31.     public static void main(String[] args) {
  32.         Scanner scan = new Scanner(System.in);
  33.         int hourOfExam = scan.nextInt();
  34.         int minOfExam = scan.nextInt();
  35.         int hourOfArrive = scan.nextInt();
  36.         int minOfArrive = scan.nextInt();
  37.         int examStart = (hourOfExam * 60) + minOfExam;
  38.         int arrive = hourOfArrive * 60 + minOfArrive;
  39.         int diff = arrive - examStart;
  40.         findStatus(diff);
  41.         difference(diff);
  42.     }
  43. }
  44. ПЪТЕШЕСТВИЕ
  45. import java.util.Scanner;
  46. public class main {
  47.     public static void main(String[] args) {
  48.         Scanner scan = new Scanner(System.in);
  49.         double budget = Double.parseDouble(scan.nextLine());
  50.         String season = scan.nextLine();
  51.         double spend = 0;
  52.         if (budget <= 100) {
  53.             System.out.println("Somewhere in Bulgaria");
  54.             if (season.equalsIgnoreCase("summer")) {
  55.                 spend = 0.30 * budget;
  56.                 System.out.printf("Camp - %.2f", spend);
  57.             }
  58.             if (season.equalsIgnoreCase("winter")) {
  59.                 spend = 0.70 * budget;
  60.                 System.out.printf("Hotel - %.2f", spend);
  61.             }
  62.         }
  63.         if (budget <= 1000 && budget > 100) {
  64.             System.out.println("Somewhere in Balkans");
  65.             if (season.equalsIgnoreCase("summer")) {
  66.                 spend = 0.40 * budget;
  67.                 System.out.printf("Camp - %.2f", spend);
  68.             }
  69.             if (season.equalsIgnoreCase("winter")) {
  70.                 spend = 0.80 * budget;
  71.                 System.out.printf("Hotel - %.2f", spend);
  72.             }
  73.         }
  74.         if(budget > 1000){
  75.             System.out.println("Somewhere in Europe");
  76.             spend = 0.90*budget;
  77.             System.out.printf("Hotel - %.2f",spend);
  78.         }
  79.     }
  80. }
  81. ОПЕРАЦИИ МЕЖДУ ЧИСЛА
  82. import java.util.Scanner;
  83.  
  84. public class main {
  85.     static boolean div(double n1, double n2 , char operator){
  86.         if ((operator == '/' || operator == '%') && n2 == 0) {
  87.             return true;
  88.         }
  89.         return false;
  90.     }
  91.     public static void main(String[] args) {
  92.         Scanner scan = new Scanner(System.in);
  93.         double n1 = scan.nextDouble();
  94.         double n2 = scan.nextDouble();
  95.         char operator = scan.next().charAt(0);
  96.         double result = 0;
  97.  
  98.         if (div(n1,n2,operator) == true){
  99.             System.out.printf("Cannot divide %.0f by zero", n1);
  100.         }
  101.  
  102.         if (div(n1,n2,operator) == false) {
  103.             switch (operator) {
  104.                 case '+':
  105.                     result += n1 + n2;
  106.                     break;
  107.                 case '-':
  108.                     result += n1 - n2;
  109.                     break;
  110.                 case '*':
  111.                     result += n1 * n2;
  112.                     break;
  113.                 case '%':
  114.                     result += n1 % n2;
  115.                     break;
  116.                 default:
  117.                     break;
  118.             }
  119.             if (operator == '/') {
  120.  
  121.                 System.out.printf("%.0f / %.0f = %.2f", n1, n2, n1 / n2);
  122.             }
  123.             if (operator != '/') {
  124.                 System.out.printf("%.0f %s %.0f = %.0f", n1, operator, n2, result);
  125.             }
  126.             if (operator == '+' || operator == '-' || operator == '*') {
  127.                 if (result % 2 == 0) {
  128.                     System.out.printf(" - even");
  129.                 } else {
  130.                     System.out.printf(" - odd");
  131.                 }
  132.             }
  133.         }
  134.     }
  135. }
  136. БИЛЕТИ ЗА МАЧ
  137. import java.util.Scanner;
  138.  
  139. public class main {
  140.     static double transport(int people, double budget) {
  141.         double transport = 0;
  142.         if (people >= 1 && people <= 4) {
  143.             transport = 0.75 * budget;
  144.         } else if (people >= 5 && people <= 9) {
  145.             transport = 0.60 * budget;
  146.         } else if (people >= 10 && people <= 24) {
  147.             transport = 0.50 * budget;
  148.         } else if (people >= 25 && people <= 49) {
  149.             transport = 0.40 * budget;
  150.         } else if (people >= 50) {
  151.             transport = 0.25 * budget;
  152.         }
  153.         return transport;
  154.     }
  155.  
  156.     public static void main(String[] args) {
  157.         Scanner scan = new Scanner(System.in);
  158.         double budget = Double.parseDouble(scan.nextLine());
  159.         String ticketKind = scan.nextLine();
  160.         int people = Integer.parseInt(scan.nextLine());
  161.         double moneyLeft = 0;
  162.         budget -= transport(people, budget);
  163.         if (ticketKind.equalsIgnoreCase("Normal")) {
  164.             budget -= 249.99*people;
  165.         } else {
  166.             budget -= 499.99*people;
  167.         }
  168.  
  169.         if (budget > 0) {
  170.             System.out.printf("Yes! You have %.2f leva left.", budget);
  171.         }else{
  172.             System.out.printf("Not enough money! You need %.2f leva.",Math.abs(budget));
  173.         }
  174.     }
  175. }
  176. ХОТЕЛСКА СТАЯ
  177. import java.util.Scanner;
  178.  
  179. public class main {
  180.     public static void main(String[] args) {
  181.         Scanner scan = new Scanner(System.in);
  182.         String season = scan.nextLine();
  183.         int nights = Integer.parseInt(scan.nextLine());
  184.         double apartment = 0;
  185.         double studio = 0;
  186.         double studioPrice = 0;
  187.         double apartmentPrice = 0;
  188.         double discountS = 0;
  189.         double discountA = 0;
  190.         if (season.equals("May") || season.equals("October")) {
  191.             studioPrice = 50;
  192.             apartmentPrice = 65;
  193.         } else if (season.equals("June") || season.equals("September")) {
  194.             studioPrice = 75.20;
  195.             apartmentPrice = 68.70;
  196.         } else if (season.equals("July") || season.equals("August")) {
  197.             studioPrice = 76;
  198.             apartmentPrice = 77;
  199.         }
  200.  
  201.         switch(season){
  202.             case "May":
  203.             case "October":
  204.                 if (nights>7){
  205.                     discountS = 0.05 * studioPrice;
  206.                 }if (nights>14){
  207.                 discountS = 0.30 * studioPrice;
  208.             }break;
  209.             case "June":
  210.             case"September":
  211.                 if (nights > 14){
  212.                     discountS = 0.20 * studioPrice;
  213.                 }break;
  214.             default:break;
  215.         }
  216.         if(nights>14){
  217.             discountA = 0.10 * apartmentPrice;
  218.         }
  219.         studioPrice-=discountS;
  220.         apartmentPrice-=discountA;
  221.         studio = studioPrice * nights;
  222.         apartment = apartmentPrice *nights;
  223.  
  224.         System.out.printf("Apartment: %.2f lv.%n",apartment);
  225.          System.out.printf("Studio: %.2f lv.",studio);
  226.     }
  227. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top