Advertisement
Spocoman

08. Fuel Tank - Part 2

Sep 17th, 2024
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.88 KB | None | 0 0
  1. package main
  2. import "fmt"
  3.  
  4. func main() {
  5.     var fuel string
  6.     fmt.Scanln(&fuel)
  7.    
  8.     var liters float64
  9.     fmt.Scanln(&liters)
  10.    
  11.     var card string
  12.     fmt.Scanln(&card)
  13.    
  14.     var literPrice = 0.0
  15.  
  16.     if (card == "No") {
  17.         if (fuel == "Gas") {
  18.             literPrice = 0.93
  19.         } else if (fuel == "Gasoline") {
  20.             literPrice = 2.22
  21.         } else if (fuel == "Diesel") {
  22.             literPrice = 2.33
  23.         }
  24.     } else {
  25.         if (fuel == "Gas") {
  26.             literPrice = 0.85
  27.         } else if (fuel == "Gasoline") {
  28.             literPrice = 2.04
  29.         } else if (fuel == "Diesel") {
  30.             literPrice = 2.21
  31.         }
  32.     }
  33.  
  34.     if (liters >= 20 && liters <= 25) {
  35.         literPrice *= 0.92
  36.     } else if (liters > 25) {
  37.         literPrice *= 0.90
  38.     }
  39.    
  40.     fmt.Printf("%.2f lv.\n", literPrice * liters)
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement