5. Write a program asking the user to enter a number. If the number is between 0 and 10, print the word blue. If the number is between 10 and 20, print the word red. If the number is between 20 and 30, print the word green. If it is any other number, print that it is not a correct colour option
Answers
Answered by
0
Answer:
I don't know whether the program you are asking for, is for Java or Python or anything else, but I am providing you the Java one..
Program:
import java.util.Scanner;
public class Number
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
if(a>0 && a<10)
{
System.out.println("Blue");
}
else if(a>10 && a<20)
{
System.out.println("Red");
}
else if(a>20 && a<30)
{
System.out.println("Green");
}
else
System.out.println("It is not a correct colour option");
}
}
Hope this might help. Thank You!
Similar questions