Hey guys I need help with in my code... I need to add a method that checks wheather the weather attributes are consistant or not.
thanks for the help heres my code...

import javax.swing.JOptionPane;
public class Week_eight_number_31 
{
private int DefaultFarenheit = 70;
private String DefaultSky = "Sunny";

public Week_eight_number_31 (String Sky,
                             int Temp)
    {
        DefaultFarenheit = Temp;
        DefaultSky = Sky;
    }
    public String getSKY ()
    {
        return DefaultSky;
    }
    public int getTEMPATURE ()
    {
        return DefaultFarenheit;
    }
    public void setSKY (String NewSky)
    {
        DefaultSky = NewSky;
    }
    public void setTEMP (int NewTemp)
    {
        if(NewTemp <= -51 || NewTemp >= 150)
            JOptionPane.showMessageDialog(null,"The Tempature is above 150 degrees or below -50 Degrees");
        else
        {
            DefaultFarenheit = NewTemp; 
        }
    }
    public static void main(String[]args)
    {
        System.out.println("============FARENHIET===========");
    Week_eight_number_31 DAY1 = new Week_eight_number_31("Sunny", 70);  
        System.out.println(DAY1.getSKY()+": "+DAY1.getTEMPATURE()+" Degrees Farenheit    =");
    Week_eight_number_31 DAY2 = new Week_eight_number_31("Winter", 20); 
        System.out.println(DAY2.getSKY()+": "+DAY2.getTEMPATURE()+" Degrees Farenheit   =");
    Week_eight_number_31 DAY3 = new Week_eight_number_31("Rainy", 50);  
        System.out.println(DAY3.getSKY()+": "+DAY3.getTEMPATURE()+" Degrees Farenheit    =");
    Week_eight_number_31 DAY4 = new Week_eight_number_31("Summer", 110);    
        System.out.println(DAY4.getSKY()+": "+DAY4.getTEMPATURE()+" Degrees Farenheit  =");
        System.out.println("================================");
        System.out.println("");
        System.out.println("=============Celsius============");
        double c1 = (DAY1.getTEMPATURE() - 32)*5/9;
        double c2 = (DAY2.getTEMPATURE() - 32)*5/9;
        double c3 = (DAY3.getTEMPATURE() - 32)*5/9;
        double c4 = (DAY4.getTEMPATURE() - 32)*5/9;
        System.out.println(DAY1.getSKY()+": "+c1+" Degrees Celsius    =");
        System.out.println(DAY2.getSKY()+": "+c2+" Degrees Celsius   =");
        System.out.println(DAY3.getSKY()+": "+c3+" Degrees Celsius    =");
        System.out.println(DAY4.getSKY()+": "+c4+" Degrees Celsius   =");
        System.out.println("================================");
    }

}

whether the weather attributes are consistant or not.

Can you define what the correct values are? What should the code do if the values are wrong?

I think i am suppose to but an if statement in the code somewhere, that should be able to tell the user that tempetures are consistent like if the valuse are all in the ball park range of 10 or so digits apart if they are not in the ball park then they are not consistence, that is what i am think it is but how can you create an if statement like that?

You mean like statement 21?
Make a list of the tests that you want to make:
less than 1000
more than 3
Then write the boolean expression that will be true if the condition is true and false if not;
(x < 1000) this will be true if x is less than 1000

Then you can connect all the boolean expressions together by using AND or OR operators:
((x < 1000) && (x > 3))
When you get all the tests you want to make, you can put that compound boolean expression in an if statement:
if((x < 1000) && (x > 3)) {...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.