Buongiorno ragazzi ho urgente bisogno del vostro aiuto, non riesco a risolvere un problema assegnato a scuola:
Data una cifra rappresentante una somma in euro, progrrammare in modo da ottenere in uscita il numero minimo di banconote rappresentante tale cifra
Il taglio max è 500 mentre il min è 1 euro
Posto il codice che ho fatto, evidentemente sbaglio qualcosa se potreste aiutarmi ve ne sarei grato.
Dim b500 As Integer
Dim b200 As Integer
Dim b100 As Integer
Dim b50 As Integer
Dim b20 As Integer
Dim b10 As Integer
Dim b5 As Integer
Dim b2 As Integer
Dim b1 As Integer
Dim c As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
c = Val(TextBox1.Text)
b500 = c / 500
c = c Mod 500
b200 = c / 200
c = c Mod 200
b100 = c / 100
c = c Mod 100
b50 = c / 50
c = c Mod 50
b20 = c / 20
c = c Mod 20
b10 = c / 10
c = c Mod 10
b5 = c / 5
c = c Mod 5
b2 = c / 2
c = c Mod 2
b1 = c
Label1.Text = Label1.Text & " 500: " & b500 & vbCrLf
Label1.Text = Label1.Text & " 200: " & b200 & vbCrLf
Label1.Text = Label1.Text & " 100: " & b100 & vbCrLf
Label1.Text = Label1.Text & " 50: " & b50 & vbCrLf
Label1.Text = Label1.Text & " 20: " & b20 & vbCrLf
Label1.Text = Label1.Text & " 10: " & b10 & vbCrLf
Label1.Text = Label1.Text & " 5: " & b5 & vbCrLf
Label1.Text = Label1.Text & " 2: " & b2 & vbCrLf
Label1.Text = Label1.Text & " 1: " & b1 & vbCrLf
Se ad esempio metto 12 lui mi dice:
500---0
200---0
100---0
50---0
20---1
10---1
5---0
2---1
1---0
NOn riesco a capire come fare mi affido a voi
Grazie in anticipo