Class 10 ICSE - Java
Class 10 ICSE - Java Input 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 to input three numbers and print their sum.
Solution:
import java.util.*; class input1 { public static void main(String[] args) { Scanner sc= new Scanner(System.in); System.out.print("Enter first number- "); int a= sc.nextInt(); System.out.print("Enter second number- "); int b= sc.nextInt(); System.out.print("Enter third number- "); int c= sc.nextInt(); int d=a+b+c; System.out.println("Total= " +d); } }
Program 2: Write a program to input two numbers and which one is greater.
Solution:
import java.util.*; class input2 { public static void main(String[] args) { Scanner sc= new Scanner(System.in); System.out.print("Enter first number- "); int a= sc.nextInt(); System.out.print("Enter second number- "); int b= sc.nextInt(); if(a>b) { System.out.println("a is greater=" +a); } System.out.println("b is greater =" +b); } }
Program 3: Write a program to print three numbers and print their product.
Solution:
import java.util.*; class input3 { public static void main(String[] args) { Scanner sc= new Scanner(System.in); System.out.print("Enter first number- "); int a= sc.nextInt(); System.out.print("Enter second number- "); int b= sc.nextInt(); System.out.print("Enter third number- "); int c= sc.nextInt(); int d=a*b*c; System.out.println("Product is= " +d); } }
Program 4: Write a program to take user input and print all even number upto that limit.
Solution:
import java.util.*; class input4 { public static void main(String[] args) { Scanner sc= new Scanner(System.in); System.out.print("Enter the limit- "); int n= sc.nextInt(); for(int i=0;i<=n;i++) { if(i%2==0) { System.out.print(i + ", "); } } } }
Program 5: Write a program to take input from the user and print all the odd integers within that limit.
Solution:
import java.util.*; class input5 { public static void main(String[] args) { Scanner sc= new Scanner(System.in); System.out.print("Enter the limit- "); int n= sc.nextInt(); for(int i=0;i<=n;i++) { if(i%2!=0) { System.out.print(i + ", "); } } } }