Gah. I wrote all this code thnking that it would work properly, but it doesn't.
//#13
//Reads N days worth of stock prices,and spits out the highest increase.
//Created 6/30/03, 8:38 PM
class StockWatcher
{
public static void main (String args [])
{
double today = 0.00; //price of stock today
double yesterday; //price of stock yesterday
//EDIT "days" TO CAHNGE THE AMOUNT OF DAYS YOU WANT THE PROGRAM TO ANALYZE. Default is 10
final int days = 10;
double everything = 0.00; // sum of everything
boolean goingup = true; //t/f value when price goes up. Original default at t
double highest = 0.00; //current highest value
double yhighest = 0.00; //highest from yesterday
double uberhighest = 0.00; //overall highest value
double minusdays = 0.00; //today - yesterday
System.out.println ("Welcome, day trader.");
System.out.println ("Enter values for " + days + " days worth of stock.");
for (int i = 1; i <= days; i++)
{
yesterday = today; //remember's the price from yesterday
today = SavitchIn.readDouble(); //collects today's value
everything += today; //changes value of price to keep updated
if (today < yesterday)
{
goingup = false;
}
if (today > yesterday)
{
minusdays = (today - yesterday);
if (minusdays > highest)
{
uberhighest = minusdays;
}
}
}
System.out.println ("The highest difference between the stock values was $" + uberhighest + ".");
}
}
I need the program to find the largest increase in the 10 numbers inputted by the user, what the difference actually was, and when it happened (i.e., bet. day 4 and 5)
Any ideas? Its due TONIGHT!!