Having trouble with "if, else" calculation statements
I am using Microsoft Visual Studio 2008 with VB.NET, and in class we were assigned this project:
A procedure should calculate a 2% price increase on all red shirts, but a 1% price increase on all other items. In addition to calculating the price increase, the procedure also should calculate the new price.
You can use the variables
strItemColr
,strItem
,decOrigPrice
,decIncrease
, anddecNewPrice
. Format the original price, price increase, and new price in thelblOriginal
,lblIncrease
, andlblNewPrice
controls, respectively.Write the Visual Ba开发者_JAVA技巧sic code.
If not an answer, just some help please. I'm 16 and I am in the highschool/college class. Our teacher teaches via Skype at the college so I am limited to her help.
I would not try to solve the problem, I will just give you hints. Is that fair? And, on purpose, I will use different variable names so it's more clear:
'Check the shirt color
If shirtColor = "Red" Then
increase1 = oldprice1 * 0.02
newPrice1 = oldPrice1 + increase1
Else
increase2 = oldPrice2 * 0.01
newPrice2 = oldPrice2 + increase2
End If
Now, to get an A from me, you would have to create an enumeration of the colors instead of teh string or use an existing enumeration like the System.Drawings.Color Strings are tricky and one spelling mistake or a capitalization of a letter and it's a different color for VB.NET
精彩评论