Hey, i'm stuck on a code. In terms of formatting it is printing out what i need, but the final degree values are displaying all the same. each new 'carbon value' should create a new value for the surface temperature. my equation is correct, but the code to get it to pick up the right carbon value I just cant figure out....
public class StageFour { public static void main(String[] args) { //Adding Carbon //Problem Parameters final double SOLAR_CONSTANT = 1367.0; final double ALBEDO = 0.3; final double STEFANBOLTZMANN = 5.67E-8; final double ORBITAL_RADIUS = 1.0; //Declare Variable double surfaceTemperature; int number; //Create a decimal format object DecimalFormat df = new DecimalFormat("#0.00"); //Equation. for (number = 280; number <= 400; number += 5) { surfaceTemperature = Math.pow((((SOLAR_CONSTANT/4)*(1.0 - ALBEDO))/(STEFANBOLTZMANN*(1.0 - (0.65 + (0.1 + 0.06*Math.log((number)/280)))/2)*(ORBITAL_RADIUS*ORBITAL_RADIUS))), 0.25) - 273.15; System.out.println("For a Carbon Level of " + number + " the Earth's Surface Temperature is " + (df.format(surfaceTemperature)) + "\u00b0" ); } } }
I should be getting lines printed from 280 to 400 with increments of 5, calculating eachof these numbers into my formula to get the appropriate degrees. on paper the equation works..
I should get something that spits numbers out like
For a Carbon Level of 280 the Earth's Surface Temperature is 13.49°
For a Carbon Level of 285 the Earth's Surface Temperature is 13.55°
For a Carbon Level of 290 the Earth's Surface Temperature is 13.61°
For a Carbon Level of 295 the Earth's Surface Temperature is 13.67° etc
but it just spits out all the same degrees values of 13.49 for each carbon level number.
Is anyway able to point out where I have gone wrong in my coding? I cant find any examples to help me out..
Cheers guys