to check wheather a number is or odd or not Scanner scan=new Scanner(System.in); int n=scan.nextInt(); if(n%2==0){ System.out.println("Even number"); }else{ System.out.println("Odd number"); } =============================================== input will be some marks and output will be grades if my marks are between 90 to 100 -> A grade 80 to 100 -> B grade 70 to 100 -> C grade 60 to 100 -> d graded 59 and below -> Sorry you are failed import java.util.*; class HelloWorld { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int marks=scan.nextInt(); if(marks<=100 && marks>=90){ System.out.println("A grade"); } else if(marks>=80 && marks<=89){ System.out.println("B grade"); } else if(marks>=70 && marks<=79){ System.out.println("C grade"); } else if(marks>=60 && marks<=69){ System.out.println("D grade"); }else{ System.out.println("Sorry you are failed"); } } } ======================================================== if my input n I want to print numbers from 1 to n in the same line with a space import java.util.*; class HelloWorld { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(); for(int i=1;i<=n;i++){ System.out.print(i+" "); } //initialization //condition check //statements //incr/decr } } ==================================================== import java.util.*; class HelloWorld { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(); int sum=0; for(int i=1;i<=n;i++){ if(i%2==1) sum=sum+i; } System.out.println(sum); //initialization //condition check //statements //incr/decr } } =============================================== Armstring number means cunbes of digits equal to sum n=153 153 = 1^3+5^3+3^3 Math.pow(1,3) =============================================