|
-
December 14th, 2010, 03:59 PM
#1
Extremely amateur code write needs help with final due tonight please help i'm stresd
Ok please help me with this, I have a final due tonight and I've tried to do this **** for like an hour now, but I have no idea how to do any of this **** with arrays and I've looked it up on the internet for like half an hour and nothing I've tried has worked.
We have to use this header: public static int threshold (double [] gains, double goal)
And this is the "psuedo-code" for part a:
i. Set earned to 0
ii. Set days to 0
iii. While earned < goal and there are still elements left in the array:
1. Add the next dayʼs increases to earned
2. Add 1 to days
3. Move to the next element in the array
iv. Decide whether to return days or -1
Then part b I have no idea about:
Complete your program by writing a main() method that asks the user to enter a profit goal. You
may define your own array of stock increase values. Your program should then calculate and print out the investment threshold for that profit goal, or state that the goal cannot be reached.
So here's what I have so far:
import java.util.*;
public class investment_thresholds
{
public static int threshold (double [] gains, double goal)
{
gains = new double{5, 3, 6};
int earned = 0;
int days = 0;
while (earned < goal)
{
earned = earned + gains;
days = days + 1;
}
}
}
But pretty much the thing that isn't working and I have no ****ing clue about is the arrays!!! If you're going to reply 'do your own work' or something gay like that than go kill yourself because I tried this for like an hour and tried everything I could to get the ****ing **** to work and I can't do it because my fat **** teacher never taught us arrays! Any help whatsoever even the slightest bit is greaty appreciated
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|