0

basically i have created a program which reads integers from a txt file and works out the averages etc. now the below code i wrote to simply state which month has the highest or lowest rainfall. below i have created the code but on compiling says there an error....can someone spot it and tell me where i have gone wrong? thank you
.............................................................................

double min = store.get(0);
		for(int i=1; i <12; i++){
		if(store.get(i)> min);
		min=store.get(i);
		
		}
		System.out.println("The Minimum Monthly Rainfall is"  + min);
		
		double max = store.get(0);
		for(int i=1; i <12; i++){
		if(store.get(i)< max);
		max=store.get(i);
		}
		System.out.println("The Maximum Monthly Rainfall is"  + max);
	}

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by thines01
0

Grn Xtrm is right. Remove the semi-colons.

Also, check this:

import	java.util.*;

class minmax
{
	public static void main(String[] args)
	{
		//assuming the "store" is a Vector of Doubles
		Vector<Double> store = new Vector<Double>();
		//
		store.add((double)8);
		store.add((double)3);
		store.add((double)7);
		store.add((double)9);
		//
		double dblMin = store.get(0);
		double dblMax = dblMin;

		//Do both checks at the same time
		for(double dbl : store)
		{
			if(dblMin > dbl)
			{
				dblMin = dbl;
			}

			if(dblMax < dbl)
			{
				dblMax = dbl;
			}
		}
		//
		System.out.println("The minimum monthly rainfall is " + dblMin +
			"\nThe maximum monthly rainfall is " + dblMax);
	}
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.