wood burning stoves 2.0
The moose likes Beginning Java and the fly likes Do whiles/Fors and Drawing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Do whiles/Fors and Drawing" Watch "Do whiles/Fors and Drawing" New topic

Do whiles/Fors and Drawing

Graham Robinson

Joined: Nov 23, 2005
Posts: 16
Hi, this code is to take 12 inputs from the user, then print the largest and average value, then print a bar chart using the drawing window to produce bars. But at the moment, i can't even get this do while etc to work, it just doesn't add the count, or maybe i have it in the wrong place, it allows me to enter as many values as i like. Any help would be great thanks,

import element.*;
import java.awt.Color;

* Prompt user for 12 values of rainful
* and produce the heaviest, average value and bar chart.
* @Author Graham Robinson
* @version 1 November 2005

public class AuchenWeather

public static void main (String[] args)

//consrtuct new console window
ConsoleWindow c = new ConsoleWindow();

// construct a drawing window object
DrawingWindow d = new DrawingWindow();

int rain, heaviest = 0, entry;
boolean valid;
float sum, average;

//for control
for(int count = 0; count < 12; count++)
c.out.println("Please input value of rainfull betweem 0 and 200mm.");
rain = c.input.readInt();
valid = (rain >= 0 && rain <= 200);
if (!valid)
c.out.println("The value entered isn't valid.");
}while (valid);

if (rain > heaviest)
heaviest = rain;
sum = 0;
average = sum / 12;
c.out.println("Heaviest rainfull = " + rain);

}//end if

}//end of for

}//end of class
}//end of main
Joanne Neal

Joined: Aug 05, 2005
Posts: 3742
Your condition should be

Graham Robinson

Joined: Nov 23, 2005
Posts: 16
Thanks, worked a treat
I agree. Here's the link: http://aspose.com/file-tools
subject: Do whiles/Fors and Drawing
It's not a secret anymore!