Advertisement
Spocoman

Metric Converter(Simple Conditions)

Oct 10th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.17 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var distance float64
  7.     fmt.Scanln(&distance)
  8.    
  9.     var inputMetric, outputMetric string
  10.     fmt.Scanln(&inputMetric)
  11.     fmt.Scanln(&outputMetric)
  12.  
  13.     if inputMetric == "m" {
  14.         distance /= 1000
  15.     } else if inputMetric == "cm" {
  16.         distance /= 100000
  17.     } else if inputMetric == "mm" {
  18.         distance /= 1000000
  19.     } else if inputMetric == "mi" {
  20.         distance /= 0.621371192
  21.     } else if inputMetric == "in" {
  22.         distance /= 39370.0787
  23.     } else if inputMetric == "ft" {
  24.         distance /= 3280.8399
  25.     } else if inputMetric == "yd" {
  26.         distance /= 1093.6133
  27.     }
  28.  
  29.     if outputMetric == "m" {
  30.         distance *= 1000
  31.     } else if outputMetric == "cm" {
  32.         distance *= 100000
  33.     } else if outputMetric == "mm" {
  34.         distance *= 1000000
  35.     } else if outputMetric == "mi" {
  36.         distance *= 0.621371192
  37.     } else if outputMetric == "in" {
  38.         distance *= 39370.0787
  39.     } else if outputMetric == "ft" {
  40.         distance *= 3280.8399
  41.     } else if outputMetric == "yd" {
  42.         distance *= 1093.6133
  43.     }
  44.  
  45.     fmt.Printf("%f", distance)
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement