Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- , * Vincent Marshall
- */
- import javax.swing.JOptionPane;
- public class U3_A8_PGM4
- {
- public static void main(String[] args)
- {
- double animStart = 0, animEnd = 0, foodStart = 0, foodEnd = 0, fAdd = 0, hour = 0;
- String aStartInput = "", fStartInput = "", fHourInput = "";
- aStartInput = JOptionPane.showInputDialog(null,"Enter the starting ammount of animals","Calculator");
- fStartInput = JOptionPane.showInputDialog(null,"Enter the starting ammount of food","Calculator");
- fHourInput = JOptionPane.showInputDialog(null,"Enter the ammount of food added each hour","Calculator");
- animEnd = Double.parseDouble(aStartInput);
- foodEnd = Double.parseDouble(fStartInput);
- fAdd = Double.parseDouble(fHourInput);
- System.out.println("Hour \t Animals at Start \t Food at Start \t Food at End \t Animals at End");
- do
- {
- hour++;
- animStart = animEnd;
- foodStart = foodEnd;
- animEnd = animStart * 2;
- foodEnd = foodStart - animStart + fAdd;
- System.out.println(hour + "\t\t" + animStart + "\t\t" + foodStart + "\t\t" + foodEnd + "\t\t" + animEnd);
- }//end loop
- while(foodEnd > animEnd);
- }//end main
- }//end class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement