16120

5.2

May 8th, 2019
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.69 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class BarStar {
  3.     public static void main(String[] args) {
  4.         Scanner scanner = new Scanner(System.in);
  5.         int beers = 200;
  6.         int wines = 300;
  7.         int bO = 0;
  8.         int bD = 0;
  9.         int wO = 0;
  10.         int wD = 0;
  11.         int quantity;
  12.         String product;
  13.  
  14.         while (true) {
  15.             String line = scanner.nextLine();
  16.             if (line.equalsIgnoreCase("END")) {
  17.                 break;
  18.             }
  19.             String lineArgs[] = line.split(": ");
  20.             product = lineArgs[0];
  21.             quantity = Integer.parseInt(lineArgs[1]);
  22.  
  23.             if (lineArgs[0].equalsIgnoreCase("Beers")) {
  24.  
  25.                 if (quantity > 0) {
  26.                     beers += quantity;
  27.                     bD++;
  28.                 } else {
  29.                     if (beers > Math.abs(quantity)) {
  30.                         beers += quantity;
  31.                         bO++;
  32.                     } else {
  33.                         System.out.println("Not enough beers!");
  34.                         continue;
  35.                     }
  36.                 }
  37.             } else if (lineArgs[0].equalsIgnoreCase("Wines")) {
  38.  
  39.                 if (quantity > 0) {
  40.                     wines += quantity;
  41.                     wD++;
  42.                 } else {
  43.                     if (wines > Math.abs(quantity)) {
  44.                         wines += quantity;
  45.                         wO++;
  46.                     } else {
  47.                         System.out.println("Not enough wines!");
  48.                         continue;
  49.                     }
  50.                 }
  51.             } }
  52.         System.out.println("Wines: " + wines);
  53.         System.out.println("Deliveries: " + wD);
  54.         System.out.println("Orders: " + wO);
  55.         System.out.println("Beers: " + beers);
  56.         System.out.println("Deliveries: " + bD);
  57.         System.out.println("Orders: " + bO);
  58.      }
  59. }
  60. -----------------------------------------------------------
  61. import java.util.Scanner;
  62.  
  63. public class MathSuperstar {
  64.     public static void main(String[] args) {
  65.         Scanner scanner = new Scanner(System.in);
  66.  
  67.         String[] line = scanner.nextLine().split(",");
  68.         double r1 = Double.parseDouble(line[0])/10;
  69.         double h1 = Double.parseDouble(line[1])/10;
  70.         double r2 = Double.parseDouble(line[2])/10;
  71.         double h2 = Double.parseDouble(line[3])/10;
  72.  
  73.         double v1 = Math.PI * (r1*r1) * h1;
  74.         double v2 = Math.PI * (r2*r2) * h2;
  75.  
  76.         if(v1 - v2 > 0){
  77.             System.out.printf("%.2f",v1);
  78.         }else if(v1 - v2 < 0){
  79.             System.out.printf("%.2f",v2);
  80.         }else{
  81.             System.out.printf("%.2f",v1);
  82.         }
  83.  
  84.     }
  85. }
Add Comment
Please, Sign In to add comment