import java.io.*;
class Ex4
{
	public static void main(String[] args)
	{

                
		Console console=System.console();
		String input;
		System.out.println("Please enter the  number");
		input=console.readLine();
		int number;
		number=Integer.parseInt(input);
                int sum;
                sum=((number/10)*10);

		switch(sum)
		{      
			case 60:
                                System.out.println("E");
                                break;

			case 70:
                                System.out.println("D");
                                break;
			case 80:
				System.out.println("C");
                         
                                break; 
			case 90: 
				System.out.println("B");
                                break;

                        case 100:
                                System.out.println("A"); 
                           
                        number=100;
				break;
			default:
				System.out.println("F");
                         break;

		}



	}


}

the instruction to this code is to make the user write numbers from 1-100 and the application should categorize the numbers in the following way

100 - A
90-99 - B
80-89 - C
70-79 - D
60-69 - E
other - F


the problem is with the other. it should go from 59 to 0.

however, the application categorizes any number as "others"

how can i cause the application to accept numbers from 0-100 and not accept numbers higher than 100?

I want to add that i cant use if or while function

You should be posting in the Java section not the C section.

Yep, wrong forum, yet I'll fix it.
String input; is wrong, change to:

String input = new String();

i thought they are both the same.

Do Apple's taste like Orange?

Edited 6 Years Ago by nbaztec: n/a

This article has been dead for over six months. Start a new discussion instead.