0
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();
				   ^
2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by Grn Xtrm
Featured Replies
  • Try changing line 8 to: [code=java] Scanner scan = new Scanner(System.in); [/code] Read More

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

  • 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. Read More

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!");
			}	
	}
}
1

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

1

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.

Edited by Grn Xtrm: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.