Silviyaa

add bags

Feb 22nd, 2021
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.81 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class O2AddBags {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.         double bagover20kg = Double.parseDouble(sc.nextLine()); //Цената на багаж над 20кг
  7.         double bagweigth = Double.parseDouble(sc.nextLine()); //Килограми на багажа
  8.         int daystilltravel = Integer.parseInt(sc.nextLine()); //Дни до пътуването
  9.         int numberofbags = Integer.parseInt(sc.nextLine()); //Брой багажи
  10.         //if statements
  11.         if (bagweigth > 20) {
  12.             double priceforbags = bagover20kg * numberofbags;
  13.             if (daystilltravel > 30) {
  14.                 double finalprice00 = priceforbags + (priceforbags * 0.10);
  15.                 System.out.printf("The total price of bags is: %.2f lv.", finalprice00);
  16.  
  17.             } else if (daystilltravel < 7) {
  18.                 double finalprice01 = priceforbags + (priceforbags * 0.40);
  19.                 System.out.printf("The total price of bags is: %.2f lv.", finalprice01);
  20.             } else {
  21.                 double finalprice02 = priceforbags + (priceforbags * 0.15);
  22.                 System.out.printf("The total price of bags is: %.2f lv.", finalprice02);
  23.  
  24.             }
  25.  
  26.         } else if (bagweigth < 10) {
  27.             double priceforbag = bagover20kg - (bagover20kg * 0.8);
  28.             double priceforbags = priceforbag * numberofbags;
  29.  
  30.             if (daystilltravel > 30) {
  31.                 double finalprice10 = priceforbags + (priceforbags * 0.10);
  32.                 System.out.printf("The total price of bags is: %.2f lv.", finalprice10);
  33.  
  34.             } else if (daystilltravel < 7) {
  35.                 double finalprice11 = priceforbags + (priceforbags * 0.40);
  36.                 System.out.printf("The total price of bags is: %.2f lv.", finalprice11);
  37.             } else {
  38.                 double finalprice12 = priceforbags + (priceforbags * 0.15);
  39.                 System.out.printf("The total price of bags is: %.2f lv.", finalprice12);
  40.  
  41.             }
  42.  
  43.         } else {
  44.             double priceforbag1 = bagover20kg / 2;
  45.             double priceforbags = priceforbag1 * numberofbags;
  46.  
  47.             if (daystilltravel > 30) {
  48.                 double finalprice20 = priceforbags + (priceforbags * 0.10);
  49.                 System.out.printf("The total price of bags is: %.2f lv.", finalprice20);
  50.  
  51.             } else if (daystilltravel < 7) {
  52.                 double finalprice21 = priceforbags + (priceforbags * 0.40);
  53.                 System.out.printf("The total price of bags is: %.2f lv.", finalprice21);
  54.             } else {
  55.                 double finalprice22 = priceforbags + (priceforbags * 0.15);
  56.                 System.out.printf("The total price of bags is: %.2f lv.", finalprice22);
  57.  
  58.             }
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment