C
C#4w ago
PapaDredd

Programming a fruit stand in visual studio

Hello I was tasked with making programming a virtual fruit stand where you click on one of the four fruit options: Banana - 65 cents per pound, Apple - $1.35 per pound, Orange - $1.60 per pound, and Pear - $1.20 per pound. Once you click the fruit the price for a pound of that fruit should be added to the total and the total should be displayed. I had a question about how to start my code for this fruit stand.
No description
3 Replies
Angius
Angius4w ago
Seems like you already got started All that's left, is register click handlers for each of the fruid buttons, and make each of them update the total value You could keep the value in a decimal private field somewhere too, since the output is text and you probably wouldn't want to be converting back and forth In pseudocode, something like this would be a start:
private decimal _total = 0.0m;

void on_banana_click() {
_total += 0.65m;
total_text = "${_total}"
}

void on_pear_click() {
// etc...
}
private decimal _total = 0.0m;

void on_banana_click() {
_total += 0.65m;
total_text = "${_total}"
}

void on_pear_click() {
// etc...
}
PapaDredd
PapaDreddOP4w ago
Ah cheers, thank you for your help. Love the Tanya pfp as well.
MODiX
MODiX4w ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?