Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class BarStar {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int beers = 200;
- int wines = 300;
- int bO = 0;
- int bD = 0;
- int wO = 0;
- int wD = 0;
- int quantity;
- String product;
- while (true) {
- String line = scanner.nextLine();
- if (line.equalsIgnoreCase("END")) {
- break;
- }
- String lineArgs[] = line.split(": ");
- product = lineArgs[0];
- quantity = Integer.parseInt(lineArgs[1]);
- if (lineArgs[0].equalsIgnoreCase("Beers")) {
- if (quantity > 0) {
- beers += quantity;
- bD++;
- } else {
- if (beers > Math.abs(quantity)) {
- beers += quantity;
- bO++;
- } else {
- System.out.println("Not enough beers!");
- continue;
- }
- }
- } else if (lineArgs[0].equalsIgnoreCase("Wines")) {
- if (quantity > 0) {
- wines += quantity;
- wD++;
- } else {
- if (wines > Math.abs(quantity)) {
- wines += quantity;
- wO++;
- } else {
- System.out.println("Not enough wines!");
- continue;
- }
- }
- } }
- System.out.println("Wines: " + wines);
- System.out.println("Deliveries: " + wD);
- System.out.println("Orders: " + wO);
- System.out.println("Beers: " + beers);
- System.out.println("Deliveries: " + bD);
- System.out.println("Orders: " + bO);
- }
- }
- -----------------------------------------------------------
- import java.util.Scanner;
- public class MathSuperstar {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String[] line = scanner.nextLine().split(",");
- double r1 = Double.parseDouble(line[0])/10;
- double h1 = Double.parseDouble(line[1])/10;
- double r2 = Double.parseDouble(line[2])/10;
- double h2 = Double.parseDouble(line[3])/10;
- double v1 = Math.PI * (r1*r1) * h1;
- double v2 = Math.PI * (r2*r2) * h2;
- if(v1 - v2 > 0){
- System.out.printf("%.2f",v1);
- }else if(v1 - v2 < 0){
- System.out.printf("%.2f",v2);
- }else{
- System.out.printf("%.2f",v1);
- }
- }
- }
Add Comment
Please, Sign In to add comment