Advertisement
Spocoman

07. Shopping

Sep 16th, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.66 KB | None | 0 0
  1. package main
  2. import "fmt"
  3.  
  4. func main() {
  5.     var budget float64
  6.     fmt.Scanln(&budget)
  7.    
  8.     var gpu, cpu, ram int
  9.     fmt.Scanln(&gpu)
  10.     fmt.Scanln(&cpu)
  11.     fmt.Scanln(&ram)
  12.        
  13.     var gpuPrice = float64(gpu) * 250
  14.     var cpuPrice = float64(cpu) * gpuPrice * 0.35
  15.     var ramPrice = float64(ram) * gpuPrice * 0.10
  16.     var totalAmount = gpuPrice + cpuPrice + ramPrice
  17.  
  18.     if (gpu > cpu) {
  19.         totalAmount *= 0.85
  20.     }
  21.    
  22.     if (budget >= totalAmount) {
  23.         fmt.Printf("You have %.2f leva left!", budget - totalAmount)
  24.     } else {
  25.         fmt.Printf("Not enough money! You need %.2f leva more!", totalAmount - budget)
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement