Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package WorkingWithAbstraction.Lab;
- import java.util.Scanner;
- public class dj {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double totalKm = Double.parseDouble(scanner.nextLine());
- double cityKm = Double.parseDouble(scanner.nextLine());
- double outsideCityKm = Double.parseDouble(scanner.nextLine());
- String taxiType = scanner.nextLine();
- double totalPriceGoing = 0;
- double totalPriceBack = 0;
- double totalPriceBothDirections = 0;
- double insideDDS = 0;
- double outsideDDS = 0;
- for (int i = 0; i <= totalKm; i++) {
- switch (taxiType) {
- case "normal":
- insideDDS = 0.90;
- outsideDDS = 0.50;
- break;
- case "sigma":
- insideDDS = 1.20;
- outsideDDS = 0.70;
- break;
- case "vip":
- insideDDS = 1.50;
- outsideDDS = 1.00;
- break;
- }
- totalPriceGoing = (cityKm * insideDDS) + (outsideCityKm * outsideDDS);
- totalPriceBack = (cityKm * insideDDS) + (outsideCityKm * outsideDDS);
- totalPriceBothDirections = totalPriceGoing + totalPriceBack;
- }
- double totalPriceWithBakshish = totalPriceBothDirections + (totalPriceBothDirections * 0.20);
- System.out.printf("%.2f", totalPriceBothDirections);
- }
- }
- // БАЛЪК version:
- // for (int i = 0; i <= totalKm; i++) {
- //
- // if (taxiType.equals("normal")){
- // totalPriceGoing = (cityKm * 0.90) + (outsideCityKm * 0.50);
- // totalPriceBack = (cityKm * 0.90) + (outsideCityKm * 0.50);
- // } else if (taxiType.equals("sigma")){
- // totalPriceGoing = (cityKm * 1.20) + (outsideCityKm * 0.70);
- // totalPriceBack = (cityKm * 1.20) + (outsideCityKm * 0.70);
- // } else if (taxiType.equals("vip")){
- // totalPriceGoing = (cityKm * 1.50) + (outsideCityKm * 1);
- // totalPriceBack = (cityKm * 1.50) + (outsideCityKm * 1);
- // }
- //
- // totalPriceBothDirections = totalPriceGoing + totalPriceBack;
- // }
- // GIGA ULTRA MEGA INFINITY PRO MASTER version:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement