# I need help...

• 04-15-2009, 05:35 PM
metaficition26
I need help...
I'm new to java programming and I'm stuck on an assignment for my class...
I've been working on this project for a while now and I'm getting kind of sick of it...I really need to turn it in though as soon as possible so can anyone help?
I'm not sure if I can apply a boolean expression to a for-each loop in this program:

public class HeatIndex
{
public static void main(String[] args)
{
String [] months = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Annual"};
double [] temp = {53.2, 56.7, 63.7, 69.7, 76.6, 81.8, 84.2, 84.2, 80.1, 72.3, 62.7, 55.2, 70.0};
int [] humi = {70, 68, 66, 67, 69, 68, 65, 65, 67, 65, 67, 69, 68};
double [] formula = new double[13];

double t = 90;
int r = 60;
double pow1 = Math.pow(10, -2);
double pow2 = Math.pow(10, -3);
double pow3 = Math.pow(10, -4);
double pow4 = Math.pow(10, -6);

for(int x = 0; x < 13; x ++)
{
formula[x] = -42.379 + (2.04901523 * temp[x]) + (10.14333127 * humi[x]) - (0.22475541 * (temp[x] * humi[x])) - ((6.83783 * pow2) * (temp[x] * temp[x])) - ((5.481717 * pow1) * (humi[x] * humi[x])) + ((1.22874 * pow2) * ((temp[x] * temp[x]) * humi[x])) + ((8.5282 * pow3) * (temp[x] * (humi[x] * humi[x]))) - ((1.99 * pow4) * ((temp[x] * temp[x]) * (humi[x] * humi[x])));
}

String title1 = "What's the Heat Index For...";
String title2 = "Victoria, Texas";
String jd = "Months";

System.out.printf("%88s%n", title1);
System.out.println();
System.out.printf("%81S%n", title2);
System.out.println();
System.out.println();
System.out.printf("%76s%n", jd);
System.out.println();

for(String mon : months)
{
System.out.printf("%10S", mon);
}
System.out.println();
System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>");
System.out.println();

for(double ture : temp)
{
System.out.printf("%10.1f", ture);
}
System.out.println();
System.out.println();

for(int h : humi)
{
System.out.printf("%10d", h);
}
System.out.println();
System.out.println();

for(double hi : formula)
{
System.out.printf("%10.1f", hi);
}

}
}

I'm trying to get the formula to print only when the tempurature is 80 degress or higher and when the humidity is 60 percent or higher...so is it doable??? Help if you can pleez!!:D
• 04-15-2009, 05:41 PM
xcallmejudasx
why not just use an if statement inside your loop?

if( (t >= 80) && (h >=60)){