File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

Do whiles/Fors and Drawing

Graham Robinson
Greenhorn

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();

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


//for control
for(int count = 0; count < 12; count++)
{
do
{
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
Rancher

Joined: Aug 05, 2005
Posts: 3446
    
  12
Your condition should be


Joanne
Graham Robinson
Greenhorn

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