Advertisement
tike

cactus1

Nov 3rd, 2015
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. /***
  2. * Read input from System.in
  3. * Use System.out.println to ouput your result.
  4. * Use:
  5. * IsoContestBase.localEcho( variable)
  6. * to display variable in a dedicated area.
  7. * **/
  8. package com.isograd.exercise;
  9. import java.util.;
  10.  
  11. public class IsoContest {
  12. public static void main( String[] argv ) throws Exception {
  13. String line;
  14. double t,d;
  15. String[] content;
  16. Scanner sc = new Scanner(System.in);
  17. while(sc.hasNextLine()) {
  18. line = sc.nextLine();
  19. content = line.split(" ");
  20. t = Double.valueOf(content[0]);
  21. d = Double.valueOf(content[1]);
  22.  
  23. System.out.println(String.format("%.2f",getPercentage(100,t,d)));
  24.  
  25. /Read the input here and perform the calculations/
  26. }
  27. /You can also perform the calculations once you have read all the data./
  28. }
  29.  
  30. public static double getPercentage(double current, double t, double d) {
  31. if (d == 0) {
  32. return current-100;
  33. }
  34. return getPercentage(current + t/100*current, t, d -1);
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement