d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Are These Pointless Variables? > They Seem Like Extra To Me(eclipse)
Add Reply New Topic New Poll
Member
Posts: 2,595
Joined: Feb 7 2007
Gold: Locked
Trader: Scammer
Warn: 30%
Nov 20 2013 12:22am
So basically, i have a method that i had to write that calculates windchill based on the parameters of temp and velocity(as doubles). They seem like there is no use for them, as they are just getting in the way of the ability to properly call the method.
I ask because this is how we are told to write this at the moment..it just seems like wasteful coding to me.
purple colored variables are the ones in question
Code

public class WindChill {
public static void main(String[] args) {
double temp, velocity, windChill;
[COLOR=purple] temp = 33;
velocity = 45;[/COLOR]
windChill = calculateWindChill(33, 45);

System.out.println("The wind chill for temperature (degrees f) = " +temp+ " and wind velocity (MPH) " +velocity+ " is " +windChill+ " degrees Fahrenheit" );
}
public static double calculateWindChill(double temp, double velocity) {
double windChill = 35.74 + 0.6215*temp - 35.75*Math.pow(velocity,0.16) + 0.4275*temp* Math.pow(velocity, 0.16);
return windChill;
}
}


Thanks for any answers =)
Member
Posts: 2,595
Joined: Feb 7 2007
Gold: Locked
Trader: Scammer
Warn: 30%
Nov 20 2013 12:23am
well it looks like you cant have color brackets in code brackets..and i cant edit posts. so heres the bare code
Code

public class WindChill {
public static void main(String[] args) {
double temp, velocity, windChill;
temp = 33;
velocity = 45;
windChill = calculateWindChill(33, 45);

System.out.println("The wind chill for temperature (degrees f) = " +temp+ " and wind velocity (MPH) " +velocity+ " is " +windChill+ " degrees Fahrenheit" );
}
public static double calculateWindChill(double temp, double velocity) {
double windChill = 35.74 + 0.6215*temp - 35.75*Math.pow(velocity,0.16) + 0.4275*temp* Math.pow(velocity, 0.16);
return windChill;
}
}


the variables are double temp and double velocity
Member
Posts: 2,595
Joined: Feb 7 2007
Gold: Locked
Trader: Scammer
Warn: 30%
Nov 20 2013 12:40am
shit, ignore this all. These instructions are not very clear and i just realized i needed to rather than assigning number values to the method's parameters i had to assign them the actual variables that they are to be..

derp
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll