clone99
New member
- Joined
- Oct 17, 2022
- Messages
- 3
- Programming Experience
- 1-3
Having problems with the following code in windosappalication(C#). The code works perfectly in the console application.
The problem is that if I I enter
Price 40;
Pay = 230;
Print it out
1 fifty dollars
1 dollar
The problem is that if I I enter
Price 40;
Pay = 230;
Print it out
1 fifty dollars
1 dollar
C#:
int price = int.Parse(tbxprice.Text); // TEXTBOX 1
int pay = int.Parse(tbxbet.Text); // text box2
int rest = pay - price;
int remainder = rest;
int fivehundred = remainder / 500;
remainder = remainder % 500;
int twohundred = remainder / 200;
remainder = remainder % 200;
int hundred = remainder / 100;
remainder = remainder % 100;
int ffemtio = remainder / 50;
remainder = remainder % 50;
int twenty = remainder / 20;
remainder = remainder % 20;
int ten = remainder / 10;
remainder = remainder % 10;
int five = remainder / 5;
remainder = remainder % 5;
int one = rest; // SEK 1
if (price > pay)
{
lblresponse.Text = " error ";
} else {
if (fivehundred != 0)
{
lblsvar.Text = fivehundred +
}
if (twohundred != 0)
{
lblsvar.Text = two hundred + "st two hundred dollar \n";
}
if (hundred != 0)
{
lblsvar.Text = hundred + "st hundred dollar \n";
}
if (ffemtio != 0)
{
lblsvar.Text = ffemtio + "st fifty dollar \n ";
}
if (twenty != 0)
{
lblsvar.Text = twenty + "st twenty dollar \n";
}
if (ten != 0)
{
lblsvar.Text = ten + "st ten dollar \n ";
}
if (five != 0)
{
lblsvar.Text = five + "st five dollar \n";
}
if (one != 0)
{
lblsvar.Text = one + " 1st dollar \n";
} else
{
lblanswer.Text = "";
}
}
Last edited by a moderator: