开发者

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, and decNewPrice. Format the original price, price increase, and new price in the lblOriginal, lblIncrease, and lblNewPrice 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜