Advertisement
Monty374

Exercise 14

Sep 28th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. package exercise.pkg14;
  2.  
  3. import javax.swing.JOptionPane;
  4.  
  5. /**
  6. *
  7. * @author Monty
  8. */
  9. public class Exercise14 {
  10.  
  11. /**
  12. * @param args the command line arguments
  13. */
  14. public static void main(String[] args) {
  15. int y;
  16. double Y, exp, t, c, b;
  17. String bacteria = JOptionPane.showInputDialog("Input Initial Bacteria");
  18. String konstant = JOptionPane.showInputDialog("Input Constant");
  19. String hours = JOptionPane.showInputDialog("Input Time in Hours");
  20. int bact = Integer.parseInt(bacteria);
  21. b = (double) bact;
  22. int constant = Integer.parseInt(konstant);
  23. c = (double) constant;
  24. int time = Integer.parseInt(hours);
  25. t = (double) time;
  26. exp = c*t;
  27.  
  28. Y = Math.pow(bact, 2);
  29.  
  30. y = (int) Y;
  31.  
  32. System.out.print("Initial bacteria: " + bact + "\n");
  33. System.out.print("Concstant value: " + c + "\n");
  34. System.out.print("Time (hours): " + t + "\n");
  35. System.out.print(y + " bacteria will be present after " + t + " hours.\n");
  36.  
  37.  
  38.  
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement