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?

Recommended Answers

All 6 Replies

Yeah...I would say your in the wrong section

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

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

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

i thought they are both the same.

java and c

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?

problem is solved.

i didnt have any problem with string

thank you

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.