## Help me complete my code.

Help me complete my code.
# 1
10-19-2009
Help me complete my code.

Ok, so I have done the 'mathematical part' just I am not sure where to put them in and how to get them to return answers.

I'd appreciate if someone could help me with:

double maxProfit(double[] prices)

Suppose that the array prices contains the daily share price for a number of days. This method calculates the maximum possible profit that you could have made on this share if you had bought it on one of the days, and sold it on one of the later days.
For example, suppose the prices are {10.80, 11.00, 10.50, 12.00, 14.00, 13.00}. Then if you have bought on day 0 and sold on day 5, you would have made \$2.20. But if you bought on day 2 and sold on day 4 you would have made \$3.50.

Not sure how to do this one, but I think that there's a need of loops.

(New to java, but know some knowledge from perl which helped me here)

~H
 HardyV2 View Public Profile for HardyV2 Find all posts by HardyV2
# 2
10-19-2009
Hello,

Why Java? If you need a GUI or web site integration you might be on the right track.

I prefer standard C due its ability to introduce pseudo classes with law enforcement taken care of by the programmer, as well as the ability to use extreme low level optimizations.

And your subject line on this post is a huge red flag.

All the Best,

Heavy J

Last edited by HeavyJ; 10-19-2009 at 10:10 PM.. Reason: typo
 HeavyJ View Public Profile for HeavyJ Find all posts by HeavyJ
# 3
10-19-2009
Huge red flag?

We are allowed to post school work after we've tried it ourselves I believe... And clearly I have, I just don't know how to get each code working.

Do I put them in the Main class? Or in the public static void main(String[] args)? and how do I get them to return values? I am not asking that you make the code for me, since I've already done...

~H
 HardyV2 View Public Profile for HardyV2 Find all posts by HardyV2
# 4
10-19-2009
HardyV2,

School work, all right... That answers the "why Java?" question.

Red Flag = way too general = not that important = don't answer me

When using extreme optimization, a programmer decides where everything should go, so that it will run as fast as computer can run it. Classes are a level of abstraction that come in handy when writing programs 50,000 lines long, otherwise they are just data structures.

In conclusion, I doubt that anyone else will look at this post because the subject line is extremely weak, and I only looked at it because I have been unemployed after getting a degree in Aerospace Engineering in 2005.

 HeavyJ View Public Profile for HeavyJ Find all posts by HeavyJ
# 5
10-20-2009
KK, thxz anyways for the time.

~H
 HardyV2 View Public Profile for HardyV2 Find all posts by HardyV2
# 6
10-20-2009
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
 pludi View Public Profile for pludi Find all posts by pludi

Test Your Knowledge in Computers #443
Difficulty: Easy
FHM, a men's lifestyle magazine, asked 1,344 women if they preferred to hang out with a computer science expert or a footballer, and 1,023 (76.116%) stated they preferred geeks over athletes.
True or False?

## Complete Code, or just Problematic Sections??

In general, would most experts, moderators and programmers, like to see the original entire script (even if very long), or just a simplified version of the problematic parts? I currently have a GNU bash function (with a lot of issues). Is it more advisable to make separate posts for each...

## 2. Homework & Coursework Questions

I have the following piece of codes. Please explain it to me in great detail how are these codes working. 1. #include <stdio.h> int main(){ int x; x=0; while (x<2 && fork()){ if (!fork()) execlp("echo","x++","x",0); x++; system("echo x+x"); } } 2. #include <stdio.h> int i;...

## A complete New Bie Here

Hello Guys I am a complete New bie in UNIX ( Just know a few of the commands ). Please guide how should I learn Unix In a proper way . I am doing a job, so i will have to do the study at home . Which books , Links, Pages you will suggest me so that i can learn UNIX fast . Thanks

## BASH complete-filename & menu-complete together

Hi, Does anyone know how to make BASH provide a list of possible completions on the first tab, and then start cycling through the possibilites on the next tab? Right now this is what I have in my .bashrc: bind "set show-all-if-ambiguous on" bind \\C-o:menu-complete This allows...

## 5. Shell Programming and Scripting

Hi All, I need some help to complete the below script, after executing below script blank lines are coming, but i am expecting 4 digit numeric no. Please solve the issue ASAP. function portno { while (true) do random=`echo \$RANDOM | cut -c 1-4` port=`netstat -a | grep -c \$random` ...

## complete noob

Hi all, This is my first post. I am a complete noobie to the UNIX OS, I have an iMac G5 with the unix shell built in and am interested in learning how to use it to do things useful with it, but have no idea where to start. I have read over the basic commands but they haven't helped me much yet....

## Auto complete

How can I set up the profile for a use so when entering a eg first charachter of a file and then pressing the tab OS will complete the file name. Thanks in advance Tom