Advertisement
Spocoman

Courier Express

Oct 6th, 2024
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.31 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var weight, standardPrice, expressPrice float64
  7.     fmt.Scanln(&weight)
  8.    
  9.     var service string
  10.     fmt.Scanln(&service)
  11.    
  12.     var distance int
  13.     fmt.Scanln(&distance)
  14.    
  15.     if weight < 1 {
  16.         standardPrice = 0.03
  17.     } else if weight >= 1 && weight < 10 {
  18.         standardPrice = 0.05
  19.     } else if weight >= 10 && weight < 40 {
  20.         standardPrice = 0.10
  21.     } else if weight >= 40 && weight < 90 {
  22.         standardPrice = 0.15;
  23.     } else if weight >= 90 && weight < 150 {
  24.         standardPrice = 0.20;
  25.     }
  26.  
  27.     if service == "express" {
  28.         if weight < 1 {
  29.             expressPrice = standardPrice * 0.80
  30.         } else if weight >= 1 && weight < 10 {
  31.             expressPrice = standardPrice * 0.40
  32.         } else if weight >= 10 && weight < 40 {
  33.             expressPrice = standardPrice * 0.05
  34.         } else if weight >= 40 && weight < 90 {
  35.             expressPrice = standardPrice * 0.02
  36.         } else if weight >= 90 && weight < 150 {
  37.             expressPrice = standardPrice * 0.01
  38.         }
  39.     }
  40.  
  41.     totalPrice := standardPrice * float64(distance) + expressPrice * float64(distance) * weight;
  42.     fmt.Printf("The delivery of your shipment with weight of %.3f kg. would cost %.2f lv.\n", weight, totalPrice);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement