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