import java.util.Scanner;

public class LazyDays
{
	public static void main (String[] args)
	{
	
	Scanner scan = new Scanner();
	
	int temp;
	
	System.out.println ("What is the current temperature?");
	temp = scan.nextInt();
	
	
		if (temp < 20)
			{
			if (temp > 95)
				{
				System.out.println("Go visit our shops!");
				}
			} 
		if (temp >= 80)
			{
			System.out.println("Go swimming!");
			}
		if (60 <= temp)
			{
			if (80 < temp)
				{
				System.out.println("Go play tennis!");
				}
			}
		if (40 <= temp)
			{
				if (temp < 60)
				{
				System.out.println("Go play golf!");
				}
			}
		if (temp < 40)
			{
			System.out.println("Go skiing!");
			}	
	}
}

Assignment says we must use cascading if statements, which is why I use them. I keep getting this error:

LazyDays.java:8: cannot find symbol
symbol  : constructor Scanner()
location: class java.util.Scanner
	Scanner scan = new Scanner();
				   ^

Recommended Answers

All 5 Replies

Try changing line 8 to:

Scanner scan = new Scanner(System.in);
commented: thanks! +0

Also had to make some logical improvements after correcting. Thank you!!!

import java.util.Scanner;

public class LazyDays
{
	public static void main (String[] args)
	{
	
	Scanner scan = new Scanner(System.in);
	
	int temp;
	
	System.out.println ("What is the current temperature?");
	temp = scan.nextInt();
	
	
		if (temp < 20)
			{
			System.out.println("Go visit our shops!");
			}
		if (temp > 95)
			{
			System.out.println("Go visit our shops!");
			}
		if (temp >= 80)
			{
			System.out.println("Go swimming!");
			}
		if (temp >= 60)
			{
			if (temp < 80)
				{
				System.out.println("Go play tennis!");
				}
			}
		if (temp >= 40)
			{
				if (temp < 60)
				{
				System.out.println("Go play golf!");
				}
			}
		if (temp < 40)
			{
			System.out.println("Go skiing!");
			}	
	}
}

Glad to help. Please mark the thread solved if you have no further questions. Thanks.

Just add [Solved] to the thread title? Or is there another option?

Scroll to the bottom of the page and click the link that says Mark As Solved (or something like that)
It will be after the last post. Thanks.

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.