Class 10 ICSE - Java

Class 10 ICSE - Java Iterative Construct Programs

Class 10th Java aims to empower students by enabling them to build their own applications introducing some effective tools to enable them to enhance their knowledge, broaden horizons, foster creativity, improve the quality of work and increase efficiency.
It also develops logical and analytical thinking so that they can easily solve interactive programs. Students learn fundamental concepts of computing using object oriented approach in one computer language with a clear idea of ethical issues involved in the field of computing
Class 10th java topics includes revision of class 9th, constructors, user-defined methods, objects and classes, library classes , etc.
Program 1: Write a program tp print the square of first 10 positive integers.
Solution:
class loop 
{  
    public static void main(String[] args) 
    {  
    int i=1;  
    while(i<=10)
    {  
    System.out.println(i*i);  
    i++;  
    }  
  }  
} 

                        
Program 2: Write a program to print the sum of first positive integers using while loop.
Solution:


class loop1 {
	public static void main(String args[])
	{
		int x = 1, sum = 0;

		// Exit when x becomes greater than 10
		while (x <= 10) {
			
			sum = sum + x;

			// Increment the value of x for
			// next iteration
			x++;
		}
		System.out.println("Sum of numbers: " + sum);
	}
}

                        

Program 3: Write a program to print the sum of squares of digits from 11 to 21 using do while loop
Solution:


// Class
class loop2{

	// Main  method
	public static void main(String args[])
	{
		
		int x = 11, sum = 0;

		// Do-while loop
		do {

			
			sum += (x*x);
			x++;
		}

		// Now checking condition
		while (x < 21);

		// Summing up
		System.out.println("Sum of squares: " + sum);
	}
}

                        

Program 4: Write a program to display sum of numbers from 1 to 20 using for loop.
Solution:


class loop3{
    public static void main(String args[])
    {
        int sum = 0;
 
        // for loop begins
        // and runs till x <= 20
        for (int x = 1; x <= 20; x++) {
            sum = sum + x;
        }
        System.out.println("Sum: " + sum);
    }
}

                        

Program 5: Write a program to print the factorial of numbers from 1 to 10.
Solution:
class numb
{  
 public static void main(String args[])
 {  
  int fact=1;  
  int n=10;  
  for(int i=1;i<=n;i++)
  {  
      for(int j=1;j<=i;j++)
      {
      fact=fact*j; 
      
      }
      System.out.println("Factorial of "+i+" is: "+fact); 
      fact=1;
     
    }  
 }
}
                        

Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com