Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1.  
  2. public class NRTest {
  3.  
  4. public static void main(String[] args) {
  5. decline(42,1,23,4,8,10);
  6. decline(100,7,615,998,801,3);
  7. decline(100,432,406,867,60,1000);
  8. }
  9.  
  10. public static void decline( int p, int a, int b, int c, int d, int n ) {
  11. System.out.println("===");
  12. double price = p * (Math.sin(a * 1 + b) + Math.cos(c * 1 + d) + 2);
  13. double highest_decline = 0, current_decline = 0;
  14. double highest_price = price;
  15. double lowest_price = price;
  16. double last_price = price;
  17.  
  18.  
  19. for (int x = 1; x <= n; x++) {
  20.  
  21.  
  22. if(price < lowest_price) {
  23. current_decline = highest_price - price;
  24. if(current_decline > highest_decline) {
  25. highest_decline = current_decline;
  26. }
  27. }
  28.  
  29. if(price > highest_price) {
  30. highest_price = price;
  31. lowest_price = price;
  32. }
  33.  
  34.  
  35. price = p * (Math.sin(a * x + b) + Math.cos(c * x + d) + 2);
  36. }
  37. System.out.println(highest_decline);
  38. System.out.println("===");
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement