Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. /*
  2. , * Vincent Marshall
  3. */
  4. import javax.swing.JOptionPane;
  5. public class U3_A8_PGM4
  6. {
  7. public static void main(String[] args)
  8. {
  9. double animStart = 0, animEnd = 0, foodStart = 0, foodEnd = 0, fAdd = 0, hour = 0;
  10. String aStartInput = "", fStartInput = "", fHourInput = "";
  11. aStartInput = JOptionPane.showInputDialog(null,"Enter the starting ammount of animals","Calculator");
  12. fStartInput = JOptionPane.showInputDialog(null,"Enter the starting ammount of food","Calculator");
  13. fHourInput = JOptionPane.showInputDialog(null,"Enter the ammount of food added each hour","Calculator");
  14. animEnd = Double.parseDouble(aStartInput);
  15. foodEnd = Double.parseDouble(fStartInput);
  16. fAdd = Double.parseDouble(fHourInput);
  17. System.out.println("Hour \t Animals at Start \t Food at Start \t Food at End \t Animals at End");
  18. do
  19. {
  20.  
  21. hour++;
  22. animStart = animEnd;
  23. foodStart = foodEnd;
  24. animEnd = animStart * 2;
  25. foodEnd = foodStart - animStart + fAdd;
  26. System.out.println(hour + "\t\t" + animStart + "\t\t" + foodStart + "\t\t" + foodEnd + "\t\t" + animEnd);
  27. }//end loop
  28. while(foodEnd > animEnd);
  29. }//end main
  30. }//end class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement