Skip to content

Instantly share code, notes, and snippets.

@freegenie
Created March 24, 2015 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freegenie/9332d7e0720ad917f684 to your computer and use it in GitHub Desktop.
Save freegenie/9332d7e0720ad917f684 to your computer and use it in GitHub Desktop.
qnt0 = 'cemento.txt'
if File.exists?(qnt0)
cemento = File.read('cemento.txt').to_i
else
cemento = 100
File.write(qnt0, cemento)
end
prod0 = 'cemento'
prez0 = 4.00
continua_ciclo = true
totale = 0
while continua_ciclo
puts ' '
puts 'Inserire prodotto da ricercare :'.center(amp + 50)
puts ' '
scelta = gets.chomp
if scelta == 'totale'
continua_ciclo = false
elsif scelta == prod0
puts 'cad.'.center(amp - 10) + prez0.to_s + ' $'
puts ' '
puts 'Quantita disponibile in magazzino: ' + cemento.to_s
puts ' '
print 'Inserire quantita richiesta: '
qnt_ric = gets.chomp.to_i
somma0 = (prez0 * qnt_ric).to_f
puts 'TOTALE: '.center(amp + 10) + somma0.to_s + ' $'
cemento = cemento - qnt_ric
puts 'Quantita rimasta: ' + cemento.to_s
puts ' '
else
puts ' '
puts 'Prodotto non presente.'
puts ' '
end
end
totale = somma0.to_f
puts ' '
puts 'SUBTOTALE: '.center(amp + 10 ) + totale.to_s + ' $'
File.write(qnt0, cemento)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment