Wind Chill Assignment!

edited September 2016 in Questions about Code

Hey guys I am completely new to programming and I have been running into some issues so I finally decided to come here for help! So, I have an assignment where I simply need to calculate Wind Chill with the formula and add in variables of whatever number I choose which are T=Temperature and V= Wind Velocity in mph I am not sure exactly how to have processing carry out my formula and actually give me the exact calculation of what it needs to be! I have tried using String but it does not seem to carry out the work i expected! If I could get someone to assist me I would be very grateful! :)

Answers

  • edited September 2016

    oh and here is what I have so far!

    //variables for tempertature and wind speed
    int T= 20;
    int V= 25;
    
    //formula for wind chill
    String F="Wind Chill=35.74+0.6215*T-35.75pow(V,0.16)+";
    String W="0.4275*Tpow(V,0.16)";
    String S= F+W;
    
    
    void setup()
    {
      size(wide,high);
      background(0,0,100);
      noStroke();
      fill(102);
      PFont font;
      font= loadFont("Chiller-Regular-48.vlw");
      textFont(font,100);
      fill(255,255,255);
      text(S,0,250);
      println(S);
    }
    

    [mod edit: code formatted]

  •     //Wind Chill Project
    
        //variables for tempertature and wind speed
        int T= 20;
        int V= 25;
    
        //formula for wind chill
        String F="Wind Chill=35.74+0.6215*T-35.75pow(V,0.16)+";
        String W="0.4275*Tpow(V,0.16)";
        String S= F+W;
    
    
        void setup()
        {
          size(wide,high);
        background(0,0,100);
        noStroke();
        fill(102);
        PFont font;
        font= loadFont("Chiller-Regular-48.vlw");
        textFont(font,100);
        fill(255,255,255);
        text(S,0,250);
    
        println(S);
    
        }
    
  • Thanks GoToLoop, I was not sure why it was coming out in such a jumbled mess..

  • edited July 2015 Answer ✓

    String datatype is for displaying & manipulating texts, not for Math:

    That is, unless you wanna rely on some script language in order to eval() them as programming statements:

    But I strongly advise you to use instead regular primitive number types like int & float:

  • edited July 2015 Answer ✓

    First of all, Mathematical operation can be used only with int or float. It cannot be used with the strings.

    If you use plus operator to add two string, it will just concatenate your strings.

    Example -

        String B = "Blyk";
        String C = "Code";
        String S = B + C;
        println(B);  //  it will print -- > Blyk
        println(C);  //  it will print -- > Code
        println(S);  //  it will print -- > Blyk Code
    

    Your corrected code.

        int T= 20;
        int V= 25;
        float Wind_Chill;
        float W ;
        void setup()
        {
          size(150, 150);
          Wind_Chill = 35.74+0.6125*T-35.75*pow(V, 0.16);
          W = 0.4275*T*pow(V, 0.16); 
          println("Wind Chill + W = ", Wind_Chill + W);
        }
    
  • Thank you guys, I wasn't expecting anyone to help this much honestly I appreciate the critique from both of you guys! I'm still very new to this and need a lot more practice of understanding how everything works!

  • edited September 2016

    Nice this is a life saver but I just need "T" & "V" not W but when I take the W out it seems to work fine.=) Awesome that helps me convert windchill to code. Blyk I have the same question on my page if you would like to put that same answer in my question to help the viewers on my question to know the answer as well. Thanks a lot man!

Sign In or Register to comment.