Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double weight = Double.parseDouble(scanner.nextLine());
- String service = scanner.nextLine();
- int distance = Integer.parseInt(scanner.nextLine());
- double standardPrice = 0, expressPrice = 0;
- if (weight < 1) {
- standardPrice = 0.03;
- } else if (weight >= 1 && weight < 10) {
- standardPrice = 0.05;
- } else if (weight >= 10 && weight < 40) {
- standardPrice = 0.10;
- } else if (weight >= 40 && weight < 90) {
- standardPrice = 0.15;
- } else if (weight >= 90 && weight < 150) {
- standardPrice = 0.20;
- }
- if (service.equals("express")) {
- if (weight < 1) {
- expressPrice = standardPrice * 0.80;
- } else if (weight >= 1 && weight < 10) {
- expressPrice = standardPrice * 0.40;
- } else if (weight >= 10 && weight < 40) {
- expressPrice = standardPrice * 0.05;
- } else if (weight >= 40 && weight < 90) {
- expressPrice = standardPrice * 0.02;
- } else if (weight >= 90 && weight < 150) {
- expressPrice = standardPrice * 0.01;
- }
- }
- double totalPrice = standardPrice * distance + expressPrice * distance * weight;
- System.out.printf("The delivery of your shipment with weight of %.3f kg. would cost %.2f lv.\n", weight, totalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement