I was just brushing through the free Java course offered on University of Helsinki and ran into a problem that I could not figure out how to solve. It takes three points (in this case temperatures) and plots it into a graph then asks you to omit any entries below -30 and above 40 degrees. Plotting was simple enough as there was an accompanying program written to actually execute the points but I can't figure out how to set the program to work within the said parameters.
This is what I have:
import java.util.Scanner;
public class Temperatures {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
while (true) {
System.out.println("Input numbers:");
double number1 = Double.parseDouble(reader.nextLine());
double number2 = Double.parseDouble(reader.nextLine());
double number3 = Double.parseDouble(reader.nextLine());
Graph.addNumber(number1);
Graph.addNumber(number2);
Graph.addNumber(number3);
if ((number1 > 40 || < -31) && (number2 > 40 || < -31) && (number3 > 40 || < -31)) {
System.out.println("Invalid parameters");
} else {
System.out.println("");
}
break;
}
}
}
Am I approaching this problem completely wrong?