No.53477 [View All]
701 posts and 493 image replies omitted. Click [Open thread] to view. ____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54194
>>54193
subtotal is one word
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54195
>>54194
not in the sample he gave me
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54196
did a messagebox show up with numbers, or does it need to be a string?
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54197
>>54196
it didn't show up, so yea
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54198
>>54197
did you select the size and style and press calculate?
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54199
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54200
>>54198
wait, yeah the messagebox, but that only needs to happen if the user hasn't selected something on the index, but yeah it works
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54201
>>54200
yes, but I'm testing to know if it's showing the correct value for the selection? not with the quantity yet though
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54202
>>54201
oh, okay. u r a smart
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54203
>>54202
i-it shows the right value?
is the quantity thing a string? where you put the quantity value?
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54204
>>54203
I don't think I did put it anywhere
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54205
>>54204
b-but where you do put the quantity value in the window you created, is it a string, or does it only accept numbers?
j-j-just keep answering my questions and I will take away your learning experience~!
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54206
>>54205
if you want to learn, you should do it by yourself
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54207
>>54205
>>54205
one sec
this is the label where the subtotal will go
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54208
>>54206
it doesn't mean that I'm getting the learning experience, it's that he's losing his, and that seems to be what he has wanted the entire past year
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54209
>>54206
but I don't really want to learn it tho, besides nothing like this in the book
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54210
>>54209
>>54207
does this help?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Smoothie_Queen_Calculator___Final_Project
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void calculatebtn_Click(object sender, EventArgs e)
{
string customername = customernametxt.Text;
int quantityval;
decimal subtotal;
decimal extras;
decimal discount;
decimal tax;
decimal total;
decimal[,] smoothieListDecimal = {{ 5.99M, 6.99M, 7.99M, 8.99M },
{ 6.99M, 7.99M, 8.99M, 9.99M }};
if (customername.Length == 0)
{
MessageBox.Show("Please enter the customer name.");
return;
}
bool tempval = Int32.TryParse(quantity.Text, out quantityval);
if (!tempval)
{
MessageBox.Show("Please enter a numeric quantity.");
return;
}
if(quantityval == 0)
{
MessageBox.Show("Quantity must not be zero.");
return;
}
total = 0m;
CalculateSubTotal();
CalculateExtras();
CalculateDiscount();
AddTax();
Finalize();
}
private void CalculateSubTotal();
{
if (sizecb.SelectedIndex != -1 && stylecb.SelectedIndex != -1)
{
subtotal = smoothieListDecimal[stylecb.SelectedIndex, sizecb.SelectedIndex];
}
else
{
MessageBox.Show("Please select size and style.");
return;
}
subtotal = subtotal * quantityval;
total += subtotal;
}
private void CalculateExtras();
{
extras = 0m;
if(echinacea.Checked)
{
extras += 0.75m;
}
if(beepollen.Checked)
{
extras += 0.75m;
}
if(energybooster.Checked)
{
extras += 0.75m;
}
extras = extras * quantityval;
total += extras;
}
private void CalculateDiscount();
{
discount = 0m;
if(discountCoupon.Checked)
{
discount = total * 0.1m;
}
else if(discountPreferred.Checked)
{
discount = total * 0.15m;
}
total -= discount;
}
private void AddTax();
{
tax = total * 0.08m;
total += tax;
}
private void Finalize();
{
subtotalText = subtotal.ToString("C");
extrasText = extras.ToString("C");
discountText = discount.ToString("C");
taxText = tax.ToString("C");
totalDueText = total.ToString("C");
}
}
}
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54211
>>54207
I assumed a few things you'll have to change
like the extras and discount radio buttons, and how to add the text to the total and stuff, and what the names are, but I think it should work okay? I put quantity back to an integer as well
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54212
>>54211
let me make a copy, so I can test it
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54213
>>54212
this will take a bit
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54214
>>54212
I made it so you can change the order of when the tax and the discount is applied too, if I did that wrong, just change the order of the CalculateDiscount and AddTax and stuff in the main part
as long as it's after the subtotal and before finalize it should be okay
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54215
>>54214
let me do it
the code I put in for the other buttons are making it freak out, and 404ing the interface I made
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54216
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54217
>>54215
do you need help debugging?
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54218
>>54217
it doesn't like it when I make private voids
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54219
>>54217
please tell me how you debug
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54220
>>54219
I'll help you once I finish poppy lunch~!
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54221
>>54219
disable the rest of the code, and try one part of it at a time, using message box things to check if it's working
comment out the extra functions and stuff and see if the quantity says "must not be zero" if you put 0 there, to make sure it's getting that far?
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54222
>>54219
most compilation errors are misspellings and such; you just check the line the error message points at
for debugging set breakpoints where you want to examine the value of a variable, run the debugger, and check that the value; if you want to test that a conditional does what you want, run up to a breakpoint before it, then step until the execution is past the conditional
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54223
>>54221
>>54222
alright I have to go pick up my brother
will do when I get back
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54224
>>54210
I didn't need the
if(quantityval == 0)
{
MessageBox.Show("Quantity must not be zero.");
return;
}
thanks
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54225
>>54224
but when you disable the void functions by commenting them out, and put that to 0, does the message box come up? does it get that far?
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54226
>>54225
hold on, I may have fingered it out
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54227
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54228
>>54226
>>54227
oki, that's good!
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54229
>>54228
okay here is what I have
I don't see this working, unless we find a way to make all these voids work together
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Smoothie_Queen_Calculator___Final_Project
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void calculatebtn_Click(object sender, EventArgs e)
{
string customername = customernametxt.Text;
int quantityval;
float quantity;
decimal subtotal;
decimal extras;
decimal discount;
decimal tax;
decimal total;
decimal[,] smoothieListDecimal = {{ 5.99M, 6.99M, 7.99M, 8.99M },
{ 6.99M, 7.99M, 8.99M, 9.99M }};
if (customername.Length == 0)
{
MessageBox.Show("Please enter the customer name");
return;
}
bool tempval = Single.TryParse(quantitytxt.Text, out quantity);
if (!tempval)
{
MessageBox.Show("Please enter a numeric quantity");
return;
}
total = 0m;
CalculateSubTotal();
CalculateExtras();
CalculateDiscount();
AddTax();
Finalize();
}
private void CalculateSubTotal()
{
decimal subtotal;
int quantityval;
decimal total = 0m;
decimal[,] smoothieListDecimal = {{ 5.99M, 6.99M, 7.99M, 8.99M },
{ 6.99M, 7.99M, 8.99M, 9.99M }};
if (sizecb.SelectedIndex != -1 && stylecb.SelectedIndex != -1)
{
subtotal = smoothieListDecimal[stylecb.SelectedIndex, sizecb.SelectedIndex];
}
else
{
MessageBox.Show("Please select size and style.");
return;
}
subtotal = subtotal * quantityval;
total += subtotal;
}
private void CalculateExtras()
{
decimal extras = 0m;
decimal total = 0m;
int quantityval;
if (echinaceacb.Checked)
{
extras += 0.75m;
}
if (beepollencb.Checked)
{
extras += 0.75m;
}
if (energyboostercb.Checked)
{
extras += 0.75m;
}
extras = extras * quantityval;
total += extras;
}
private void CalculateDiscount()
{
decimal discount = 0m;
decimal total = 0;
if (couponrb.Checked)
{
discount = total* 0.1m;
}
else if(preferredrb.Checked)
{
discount = total* 0.15m;
}
total -= discount;
}
private void AddTax()
{
decimal tax;
decimal total;
tax = total* 0.08m;
total += tax;
}
private void Finalize()
{
subtotallbl.Text = subtotal.ToString("C");
extraslbl.Text = extras.ToString("C");
discountlbl.Text = discount.ToString("C");
salestaxlbl.Text = tax.ToString("C");
amountduelbl = total.ToString("C");
}
private void exitbtn_Click(object sender, EventArgs e)
{
this.Close();
}
private void clearbtn_Click(object sender, EventArgs e)
{
}
private void aboutbtn_Click(object sender, EventArgs e)
{
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54230
>>54229
also the comboboxes aren't displaying the messagebox anymore
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54231
>>54147
Aw…
>>54180
Good lad ^^
>>54148
>>54152
Happy December Poppy-chan. I hope you will stop giving us flak for being silly now!
>>54153
>>54229
So, if I see correctly, this shouldn't work because you are defining total in all of these subprocedures - every procedure has its own total, but they are independent of one another. You need to make it one variable, and it needs to be visible from within all of these procedures. I assume it should be possible to define it within the body of the Form1 class. I think you should probably do it with all of the variables that you are going to display on the form, so, total, subtotal, extras, discount, sales tax
Also, I think that the line
total = 0m;
should not be in any of the the calculate procedures, that should be in the button that clears the form, yeah? So you could for example punch in different kinds of smoothies and different quantities and if you click calculate multiple times, it adds all of these orders into a single one, yeah?
Also wait, how come you don't get errors in
private void Finalize()
you are using variables in it which are not defined anywhere, right?
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54232
>>54231
hey mouse
did your school go well
yeah
I get errors
I just want this to work, so I don't have to think about it anymore
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54233
>>54232
if you don't figure it out in 20 or 30 minutes, I will have free time again to try to figure it out with you~
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54234
>>54231
total is defined once, through out there, I add to the total as it goes, since the total is what taxes and discount are based on at different stages, so it needs to be different as it goes
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54235
>>54233
thank you for all your help, poppy
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54236
>>54232
Hello hello.
We had a flamboyant lecturer (in mannerisms, not appearance) teach us about Sigmund Freud. And after school I went to the Christmas season fair and bought two bottles of mead. So overall, some great stuff with lots of boredom in between.
Ah! Well then, you would probably best define those variables I mentioned right under where the class begins
public partial class Form1 : Form
{
decimal subtotal;
decimal extras;
decimal discount;
decimal tax;
decimal total;
decimal[,] smoothieListDecimal = {{ 5.99M, 6.99M, 7.99M, 8.99M },
{ 6.99M, 7.99M, 8.99M, 9.99M }};
. . . . . .
But then you must not define them anywhere else, so make sure to delete these definitions in calculatebtn_Click
>>54234
>total is defined once
It is, but it is not visible in the other procedures! The other procedures have no idea there is such a thing as the variable called total, so it must be throwing errors.
Also, how do you make 8chan colourcode the code? I only know about the plain [ code ] tag
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54237
>>54236
so something like
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Smoothie_Queen_Calculator___Final_Project
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void calculatebtn_Click(object sender, EventArgs e)
{
string customername = customernametxt.Text;
decimal quantityval;
float quantity;
decimal subtotal;
decimal extras;
decimal discount;
decimal tax;
decimal total;
int extras = 0m;
decimal[,] smoothieListDecimal = {{ 5.99M, 6.99M, 7.99M, 8.99M },
{ 6.99M, 7.99M, 8.99M, 9.99M }};
if (customername.Length == 0)
{
MessageBox.Show("Please enter the customer name");
return;
}
bool tempval = Single.TryParse(quantitytxt.Text, out quantity);
if (!tempval)
{
MessageBox.Show("Please enter a numeric quantity");
return;
}
if (sizecb.SelectedIndex != -1 && stylecb.SelectedIndex != -1)
{
subtotal = smoothieListDecimal[stylecb.SelectedIndex, sizecb.SelectedIndex];
}
else
{
MessageBox.Show("Please select size and style.");
return;
}
subtotal = subtotal * quantityval;
total += subtotal;
if (echinaceacb.Checked)
{
extras += 0.75m;
}
if (beepollencb.Checked)
{
extras += 0.75m;
}
if (energyboostercb.Checked)
{
extras += 0.75m;
}
extras = extras * quantityval;
total += extras;
if (couponrb.Checked)
{
discount = total * 0.1m;
}
else if (preferredrb.Checked)
{
discount = total * 0.15m;
}
total -= discount;
tax = total * 0.08m;
total += tax;
subtotallbl.Text = subtotal.ToString("C");
extraslbl.Text = extras.ToString("C");
discountlbl.Text = discount.ToString("C");
salestaxlbl.Text = tax.ToString("C");
amountduelbl = total.ToString("C");
}
private void exitbtn_Click(object sender, EventArgs e)
{
this.Close();
}
private void clearbtn_Click(object sender, EventArgs e)
{
}
private void aboutbtn_Click(object sender, EventArgs e)
{
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54238
>>54237
Well no. Because even if you do all of the calculation in one procedure, the values will get erased the next time you click the button and the procedure launches again.
If someone adds a king sized smoothie, you click calculate and it gives you the subtotal and a total. And then if they want to add two normal smoothies, you click calculate and it gives you a different subtotal and it gets added to the previous total, yes?
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54239
>>54238
i have no idea
it doesn't have anything to save the data from the last order, i don't think so
idk really, as I have no way of testing anything
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54240
>>54236
total only needs to be defined once
>>54237
yes, you can have them all in the main function, the other functions were just to make it more readable
>>54238
no, it's just one calculation, that's why there's a quantity button
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54241
>>54240
I thought it just helped with them all come together
I think I am just going to buy the answer.
you were still a very big help, poppy
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54242
>>54240
I know, but it needs to be somewhere where the other procedures can see it ^.^
>>54240
>no, it's just one calculation, that's why there's a quantity button
I thought it was meant to add multiple orders and combine them together. So that you could for example choose 1 king sized smoothie and click the button, it gets added, then 2 normal sized smoothies with extras and click, it gets added.
>>54239
>it doesn't have anything to save the data from the last order, i don't think so
It would if you defined it in the class.
>>54240
And how do I do the fancy coloured code please?
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.54243
>>54241
I'm here now. what? that's silly, it's literally done already, we just need to debug it
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.