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 &#40;int i = 1; i <= days; i++&#41;
		&#123;
			yesterday = today; //remember's the price from yesterday

			today = SavitchIn.readDouble&#40;&#41;; //collects today's value
			
			everything += today; //changes value of price to keep updated
			
			if &#40;today < yesterday&#41;
			&#123;
				goingup = false;
			&#125;
			if &#40;today > yesterday&#41;
			&#123;
				minusdays = &#40;today - yesterday&#41;;
				if &#40;minusdays > highest&#41;
				&#123;
					uberhighest = minusdays;
				&#125;
			&#125;		
		&#125;
		System.out.println &#40;"The highest difference between the stock values was $" + uberhighest + "."&#41;;
	&#125; 
&#125;

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!!

Please explain what happens when you compile and execute the program.
Do you get errors? If so copy the full text and paste here.
Is the output from the programn wrong? If so copy the console from when you execute the code and paste it here and add some comments describing what the output should be.

Please fix the posted code. It is full of special characters: &#40; that are not valid java.

This article has been dead for over six months. Start a new discussion instead.