• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Eggs Profit and Loss

 
Greenhorn
Posts: 23
Android Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Happy New Year To Everybody!!!

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.
Michael
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the error/output you are getting? Try removing the print statements between the Scanner calls. I think even the print statements will be taken as the input to the Scanner.
 
Michael Humphreys
Greenhorn
Posts: 23
Android Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
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?
230
What is the cost of feed?
600
What is the price of eggs
2.35
How many eggs did you gather?
230
 
Michael Humphreys
Greenhorn
Posts: 23
Android Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Michael
 
reply
    Bookmark Topic Watch Topic
  • New Topic