Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class NRTest {
- public static void main(String[] args) {
- decline(42,1,23,4,8,10);
- decline(100,7,615,998,801,3);
- decline(100,432,406,867,60,1000);
- }
- public static void decline( int p, int a, int b, int c, int d, int n ) {
- System.out.println("===");
- double price = p * (Math.sin(a * 1 + b) + Math.cos(c * 1 + d) + 2);
- double highest_decline = 0, current_decline = 0;
- double highest_price = price;
- double lowest_price = price;
- double last_price = price;
- for (int x = 1; x <= n; x++) {
- if(price < lowest_price) {
- current_decline = highest_price - price;
- if(current_decline > highest_decline) {
- highest_decline = current_decline;
- }
- }
- if(price > highest_price) {
- highest_price = price;
- lowest_price = price;
- }
- price = p * (Math.sin(a * x + b) + Math.cos(c * x + d) + 2);
- }
- System.out.println(highest_decline);
- System.out.println("===");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement