This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
My final project for my university is to enhance my code in order to have it print out the total price including the discount but before shipping charges and taxes. The rows should be items sold and the columns should be the wait of the items. I am starting to get frustrated, been at this for hours cant seem to figure it out. As a hint he says to use nested loops?
Heres my codes I have 1 main class and 1 test class
and my Main Class
Thanks for all the help ive been really struggling!
No offense, but your code is kind of a mess... You don't follow conventions, so it gets very confusing. For example, when I see "Items", Since the first letter is capitalized, I think it is a class, not a reference.
You have a class called "DataEquations", but then make a reference variable it called 'price'. A price is not an equation, or a set of equations...a price should be (at least in my mind) a number.
On line 21 of your PriceCalculator class, you have a while loop, with an...odd...condition. I'm not saying it is wrong, but it doesn't look like anything that makes any sense to me. Why have these magic numbers?
Your while statement doesn't have any curly braces, so there is only one line in it's body. So let's assume I input a value of '2'. Since 2 is not <= 0, or > 10000000 (however many 0's you have), it skips the loop body, which is only the line 24. Then lines 26-45 all run.
Now, let's assume i put in a value of "-2". This makes the condition TRUE, and now i'm stuck in an infinite loop printing "Base Price = $-84.00" (or whatever price I input) forever, since you never change anything that would affect your condition.
so...I am assuming you need some major revisions to your code here. I would guess that you are supposed to ask the user how many items to ship (that part seems to work). I would then guess that you need a loop that gets the input weight of each and every item, one at a time, an stores all those values in a collection of some kind (and Array or ArrayList would work fine).
Once you have that done, I would work on printing out the data for each element.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors