This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am continuing my project Eggs Profit and Loss. I am now adding an input to the program so user can input the variables and the program would give the user the result. I have read one tutorial and this is what I came up with:
The problem is the program does nothing so I think the problem lies in the system scanner call...but I don't know where.
I do thank you all for the help so far.
Well I figured this one out on my own. lol I was missing a line. I actually have two different ways of doing it. one producis the input on the same line as the string and the other puts the input below the string so all is well ty again.
here is the code I came up with:
Here is the output:
Number of chickens: 250
How many of your chickens are laying hens?
What is the cost of feed?
What is the price of eggs
How many eggs did you gather?
I just wanted to post my clean copy of code so if some one is following this thread they can refrance good code. At least that is my intentions lol.
Here is the code:
and the result:
How many eggs did you gather?1000
The price of eggs? 2.25
Number Of Chickens =1000
Number Of Hens = 1000
Number Of Eggs Laid = 30000.0
CostOf Feed =500.0
Loss = -312.5
OH No, You had a loss!! What's the price of chicken meat???
The next phase of this project is to build a GUI to ask for the variable input. I am sure I will have questions LOL.