Menu

#682 Errors on Lesson 23 Temperatures

Week1
closed
nobody
None
2015-01-15
2015-01-14
Anonymous
No

High I'm having issues with the "test code" part of lesson 23 Temperatures. The error messages report that the program is adding numbers to the graph that should be excluded. But, when I run the program, I can't duplicate those errors. For example, the number 1000 does not graph when I run it. But I receive an error stating that, "The number 1000 should not be added to the graph." when I submit for testing. Any suggestions would be greatly appreciated. Thank you.

Sincerely,

Joshua Sitton
rmhtxjas@msn.com

Discussion

  • Anonymous

    Anonymous - 2015-01-14

    Here is the code by the way:

    import java.util.Scanner;

    public class Temperatures {

    public static void main(String[] args) {
    
        while (true) {
            System.out.print("Enter a daily temperature: ");
            Scanner reader = new Scanner(System.in);
            double dailyTemp = Double.parseDouble(reader.nextLine());
    
            if (dailyTemp > -31.0 && dailyTemp < 41.0) {
            Graph.addNumber(dailyTemp);
    
            }
    
                }
    
    
    
        // Graph is used as follows:
    
    
        //Graph.addNumber(dailyTemp);
        // Remove or comment out these lines above before trying to run
    }
    

    }

     
  • Joni

    Joni - 2015-01-14

    Hi,

    You should only create one scanner, so remove Scanner declaration from the loop.

    BR
    Joni

     
  • Anonymous

    Anonymous - 2015-01-14

    Thank you! That was exactly it. I knew it was something very basic like that. I was hesitant to ask for help, but I'm glad I did. It could have taken me forever to figure that out on my own. So, once again thanks.

     
  • Joni

    Joni - 2015-01-15
    • status: open --> closed
     
MongoDB Logo MongoDB