Table of Contents
Top ICSE Board 10th repeated JAVA Programs
The ICSE Class 10 Computer Applications syllabus emphasizes a strong foundation in Java programming. Preparing effectively requires a focus on essential programs that cover key concepts, logic-building, and syntax. This article provides a carefully curated list of ICSE Board 10th important JAVA Programs for exam preparation. Each program is designed to test your understanding of core topics, including decision-making, loops, switch-case, and user-defined logic.
From determining whether a number is positive, even, or odd to writing programs that categorize student grades, these exercises help enhance your problem-solving skills. You’ll also find programs to check leap years, display days of the week based on user input, and handle invalid entries gracefully. Special attention is given to understanding the behavior of break
and fall-through in switch-case statements.
Additionally, this article features a menu-driven program for arithmetic operations, enabling you to practice implementing user choices dynamically. Another essential example demonstrates how to find the largest of three numbers using an if-else-if
ladder, reinforcing conditional logic.
By working through these examples, you’ll build confidence and fluency in Java programming, ensuring you’re well-prepared for both the theory and practical exams. These programs are a step toward achieving success in your ICSE Class 10 board exams.
Question: Write a program to check if a number is positive.
//positive
import java.util.*;
class PositiveCheck
{
void main()
{
Scanner sc=newScanner(System.in);
int number;
System.out.println(“Enter any number:”);
number=sc.nextInt();
if (number > 0)
{
System.out.println(number + " is positive.");
}
else
{
System.out.println(number + “is negative.”);
}
}}
Output:
Input:
Enter any number: 10
10 is positive.
Input:
Enter any number: -9
-9 is negative.
Question: Write a program to check whether a number is even or odd.
//even or odd
import java.util.*;
class EvenOdd
{
void main()
{
Scanner sc=newScanner(System.in);
int number;
System.out.println(“Enter any number:”);
number=sc.nextInt();
if (number % 2 == 0)
{
System.out.println(number + " is even.");
}
else
{
System.out.println(number + " is odd.");
}
}
}
Output:
Input:
Enter any number: 6
6 is even.
Input:
Enter any number: 5
5 is odd.
Question: Write a program to categorize a student’s grade based on marks.
//student’s grades
import java.util.*;
class GradeCategorizer
{
void main()
{
Scanner sc=newScanner(System.in);
int marks;
System.out.println(“Enter marks of the student:”);
marks=sc.nextInt();
if (marks >= 90)
{
System.out.println("Grade: A+");
}
else
if (marks >= 75)
{
System.out.println("Grade: A");}
else
if (marks >= 50)
{
System.out.println("Grade: B");
}
else
{
System.out.println("Grade: F");
}
}
}
Output:
Input:
Enter marks of the student: 92
Grade: A
Write a program to check whether a year is a leap year.
//leap year check
import java.util.*;
class LeapYear
{
void main()
{
Scanner sc=newScanner(System.in);
int year;
System.out.println(“Enter year:”);
number=sc.nextInt();
if (year % 4 == 0)
{
if (year % 100 != 0 || year % 400 == 0)
{
System.out.println(year + " is a leap year.");
}
else
{
System.out.println(year + " is not a leap year.");
}
}
else
{
System.out.println(year + " is not a leap year.");
}
}
}
Output:
Input:
Enter year: 2024
2024 is a leap year.
Question: Write a program to display the day of the week based on a number input.
//day
import java.util.*;
class DayOfWeek
{
void main()
{
Scanner sc=newScanner(System.in);
int day;
System.out.println(“Enter day number:”);
day=sc.nextInt();
switch (day)
{
case 1: System.out.println("Monday");
break;
case 2: System.out.println("Tuesday");
break;
case 3: System.out.println("Wednesday");
break;
case 4: System.out.println("Thursday");
break;
case 5: System.out.println("Friday");
break;
case 6: System.out.println("Saturday");
break;
case 7: System.out.println("Sunday");
break;
default: System.out.println("Invalid day number.");
}
}
}
Output:
Input:
Enter day number: 3
Wednesday
Write a program to display a message if an invalid choice is entered.
//default
import java.util.*;
class InvalidChoice
{
void main()
{
int choice;
Scanner sc=newScanner(System.in);
System.out.println(“Enter choice:”);
choice=sc.nextInt();
switch (choice)
{
case 1: System.out.println("Option 1 selected.");
break;
case 2: System.out.println("Option 2 selected.");
break;
case 3: System.out.println("Option 3 selected.");
break;
default: System.out.println("Invalid choice!");
}
} }
Output:
Input:
Enter choice: 5
Invalid choice!
Write a program to demonstrate the use of break in a switch-case
//break
import java.util.*;
class BreakDemo
{
void main()
{
int choice;
Scanner sc=newScanner(System.in);
System.out.println(“Enter choice:”);
choice=sc.nextInt();
switch (choice)
{
case 1:
System.out.println("Case 1 executed.");
break;
case 2:
System.out.println("Case 2 executed.");
break;
case 3:
System.out.println("Case 3 executed.");
break;
default:
System.out.println("No matching case.");
}
}
}
Output:
Input:
Enter choice: 2
Case 2 executed.
Write a program to demonstrate fall-through behavior in switch-case.
//fall-through
import java.util.*;
class FallThrough
{
void main()
{
Scanner sc=newScanner(System.in);
int num;
System.out.println(“Enter any number:”);
num=sc.nextInt();
switch (num)
{
case 1: System.out.println("Case 1");
case 2: System.out.println("Case 2");
case 3: System.out.println("Case 3");
default: System.out.println("Default case");
}
}
}
Output:
Input:
Enter any number: 2
Case 2
Case 3
Default case
Write a menu-driven program to perform arithmetic operations.
//arithmetic operations
import java.util.*;
class MenuDriven
{
void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Menu:");
System.out.println("1. Addition");
System.out.println("2. Subtraction");
System.out.println("3. Multiplication");
System.out.println("4. Division");
System.out.println("Enter your choice: ");
int choice = sc.nextInt();
System.out.println("Enter two numbers: ");
int a = sc.nextInt();
int b = sc.nextInt();
switch (choice)
{
case 1: System.out.println(" The Result is: " + (a + b));
break;
case 2: System.out.println("The Result is: " + (a - b));
break;
case 3: System.out.println("The Result is: " + (a * b));
break;
case 4:
if (b != 0)
{
System.out.println("The Result is: " + (a / b));
}
else
{
System.out.println("Division by zero not allowed.");
}
break;
default: System.out.println("Invalid choice!");
}
}
}
Menu:
1. Addition
2. Subtraction
3. Multiplication
4. Division
Input:
Enter your choice:
2
Enter two numbers:
8
3
Result: 5
Write a program to terminate execution based on user input.
//terminating execution
import java.util.*;
class TerminateProgram
{
void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Do you want to continue? (yes/no): ");
String response = sc.nextLine();
if (response.equalsIgnoreCase("no"))
{
System.out.println("Program terminated.");
System.exit(0);
}
System.out.println("Program continues...");
}
}
Output:
Input:
Do you want to continue? (yes/no):
no
Program terminated.
Write a program to find the maximum of three numbers using an if-else-if ladder.
//maximum of three numbers
import java.util.Scanner;
class MaxOfThree
{
void main()
{
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();
if (a >= b && a >= c)
{
System.out.println("Maximum: " + a);
}
else
if (b >= a && b >= c)
{
System.out.println("Maximum: " + b);
}
else
{
System.out.println("Maximum: " + c);
}
}
}
Output:
Input: 7, 3, 5
Output: Maximum: 7.
Checking Eligibility to Vote (If Statement)
Write a program to check if a person is eligible to vote based on their age.
//VOTE
import java.util.*;
class VotingEligibility
{
void main()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter your age: ");
int age = sc.nextInt();
if (age >= 18)
{
System.out.println("You are eligible to vote.");
}
else
{
System.out.println(“You are not eligible to vote.”);
}
}
}
Output:
Input:
Enter your age: 20
You are eligible to vote.
Online Shopping Discount (If-Else Statement)
Write a program to calculate the discount based on a purchase amount.
//calculating discount
import java.util.*;
class DiscountCalculator
{
void main()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter total purchase amount: ");
double amount = sc.nextDouble();
if (amount >= 500)
{
System.out.println("You get a 10% discount!");
System.out.println("Final amount: " + (amount * 0.90));
}
else
{
System.out.println("No discount applied.");
System.out.println("Final amount: " + amount);
}
}
}
Output:
Input:
Enter total purchase amount: 600
You get a 10% discount!
Final amount: 540.0
Movie Ticket Pricing (If-Else-If Ladder)
Write a program to display ticket price based on age.
//ticket price
import java.util.*;
class MovieTicket
{
void main()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter your age: ");
int age = sc.nextInt();
if (age < 12)
{
System.out.println("Ticket Price: $5");
}
else
if (age <= 60)
{
System.out.println("Ticket Price: $10");
}
else
{
System.out.println("Ticket Price: $7");
}
}
}
Output:
Input:
Enter your age: 65
Ticket Price: $7
Traffic Light Simulator (Switch-Case)
Write a program to display actions based on traffic light color.
//actions on traffic light
import java.util.*;
class TrafficLight
{
void main()
{
Scanner sc = new Scanner(System.in);
System.out.print(“Enter traffic light color (red/yellow/green): “);
String color = sc.nextLine().toLowerCase();
switch (color)
{
case “red”:
System.out.println(“Stop!”);
break;
case “yellow”:
System.out.println(“Get ready to move.”);
break;
case “green”:
System.out.println(“Go!”);
break;
default:
System.out.println(“Invalid color.”);
}
}
}
Output:
Input:
Enter traffic light color (red/yellow/green): green
Go!
Temperature Monitoring (Nested If)
Write a program to categorize temperature as hot, cold, or normal.
//hot cold normal
import java.util.Scanner;
class TemperatureMonitor
{
void main()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter temperature in Celsius: ");
int temp = sc.nextInt();
if (temp > 0)
{
if (temp > 30)
{
System.out.println("It's hot.");
}
else
{
System.out.println("It's normal.");
}
}
else
{
System.out.println("It's cold.");
}
}
}
Output:
Input:
Enter temperature in Celsius: 15
It’s normal.
Coffee Machine (Menu-Driven Program)
Write a menu-driven program for ordering coffee.
//ordering coffee
import java.util.Scanner;
class CoffeeMachine
{
void main()
{
Scanner sc = new Scanner(System.in);
System.out.println(“Menu:”);
System.out.println(“1. Espresso – $3”);
System.out.println(“2. Cappuccino – $4”);
System.out.println(“3. Latte – $5”);
System.out.print(“Enter your choice (1-3): “);
int choice = sc.nextInt();
switch (choice)
{
case 1:
System.out.println(“You ordered Espresso. Pay $3.”);
break;
case 2:
System.out.println(“You ordered Cappuccino. Pay $4.”);
break;
case 3:
System.out.println(“You ordered Latte. Pay $5.”);
break;
default:
System.out.println(“Invalid choice. Please try again.”);
}
}
}
Output:
Menu:
1. Espresso – $3
2. Cappuccino – $4
3. Latte – $5
Input:
Enter your choice (1-3): 2
You ordered Cappuccino. Pay $4.
Electricity Bill Calculator (If-Else-If Ladder)
Write a program to calculate electricity charges based on units consumed.
//electricity bill calculation
import java.util.*;
class ElectricityBill
{
void main()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter units consumed: ");
int units = sc.nextInt();
double bill;
if (units <= 100)
{
bill = units * 1.5;
}
else
if (units <= 300)
{
bill = 100 * 1.5 + (units - 100) * 2.0;
}
else
{
bill = 100 * 1.5 + 200 * 2.0 + (units - 300) * 3.0;
}
System.out.println("Electricity Bill: $" + bill);
}
}
Output:
Input:
Enter units consumed: 250
Electricity Bill: $450.0
Restaurant Tip Calculator (Nested If)
Write a program to calculate the tip based on the bill amount.
//restaurant
import java.util.Scanner;
class TipCalculator
{
void main()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the bill amount: ");
double bill = sc.nextDouble();
double tip;
if (bill > 0)
{
if (bill < 50)
{
tip = bill * 0.10;
}
else if (bill <= 100)
{
tip = bill * 0.15;
}
else
{
tip = bill * 0.20;
}
System.out.println("Tip amount: $" + tip);
}
else
{
System.out.println("Invalid bill amount.");
}
}
}
Output:
Input:
Enter the bill amount: 120
Tip amount: $24.0
Password Authentication (If-Else)
Write a program to authenticate a user based on a password.
//password authentication
import java.util.Scanner;
class PasswordAuth
{
void main()
{
Scanner sc = new Scanner(System.in);
final String PASSWORD = "java123";
System.out.print("Enter password: ");
String input = sc.nextLine();
if (input.equals(PASSWORD))
{
System.out.println("Access granted!");
}
else
{
System.out.println("Access denied.");
}
}
}
Output:
Input:
Enter password: java123
Access granted!
Water Bill Calculator
Write a program to calculate the water bill based on usage in liters.
//water bill calculation
import java.util.*;
class WaterBill
{
void main()
{
Scanner sc=new Scanner(System.in);
int usage;
System.out.println(“Enter usage:”);
usage=sc.nextInt();
double bill;
if (usage <= 500)
{
bill = usage * 0.5;
}
else
if (usage <= 1500)
{
bill = 500 * 0.5 + (usage - 500) * 0.75;
}
else
{
bill = 500 * 0.5 + 1000 * 0.75 + (usage - 1500) * 1.0;
}
System.out.println("Water Bill: $" + bill);
}
}
Output:
Input:
Enter usage: 1200
Water Bill: $875.0
Online Quiz System
Write a program to check the correct answer to a multiple-choice question.
//online quiz system
import java.util.Scanner;
class Quiz
{
void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("What is the capital of France?");
System.out.println("1. Berlin");
System.out.println("2. Madrid");
System.out.println("3. Paris");
System.out.println("4. Rome");
System.out.print("Enter your choice (1-4): ");
int choice = sc.nextInt();
switch (choice)
{
case 3:
System.out.println("Correct Answer!");
break;
default:
System.out.println("Wrong Answer.");
}
}
}
Output:
What is the capital of France?
1. Berlin
2. Madrid
3. Paris
4. Rome
Input:
Enter your choice (1-4): 3
Correct Answer!
Bank ATM Withdrawal
Write a program to simulate ATM withdrawal with a limit check.
//bankATM
import java.util.*;
class ATMWithdrawal
{
void main()
{
Scanner sc=new Scanner(System.in):
int balance, withdrawalAmount;
System.out.println(“Enter balance:”);
balance=sc.nextInt();
System.out.println(“Enter withdrawal amount:”);
withdrawalAmount=sc.nextInt();
if (withdrawalAmount > balance)
{
System.out.println(“Insufficient balance.”);
}
else
if (withdrawalAmount > 5000)
{
System.out.println(“Withdrawal limit exceeded.”);
}
else
{
balance -= withdrawalAmount;
System.out.println(“Withdrawal successful. Remaining balance: $” + balance);
}
}
}
Output:
Input:
Balance: $10000
withdrawalAmount: $2000
Withdrawal successful. Remaining balance: $8000
Restaurant Menu
Write a program to display a menu and calculate the bill for an order.
//menu and bill
import java.util.*;
class RestaurantMenu
{
void main()
{
Scanner sc=new Scanner(System.in):
int choice, quantity;
System.out.println(“Enter choice:”);
choice=sc.nextInt();
System.out.println(“Enter quantity:”);
quantity=sc.nextInt();
double price;
switch (choice)
{
case 1: price = 50.0; break; // Burger
case 2: price = 30.0; break; // Sandwich
case 3: price = 20.0; break; // Coffee
default:
System.out.println("Invalid choice.");
return;
}
System.out.println("Total Bill is: $" + (price * quantity));
}
}
Output:
Input:
Enter choice: 2
Enter quantity: 3
Total Bill: $90.0
Grade Calculator
Write a program to calculate the grade based on marks using a switch-case.
//calculate grade
import java.util.*;
class GradeSwitch
{
void main()
{
Scanner sc=new Scanner(System.in):
int marks;
System.out.println(“Enter marks:”);
marks=sc.nextInt();
switch (marks / 10)
{
case 10:
case 9: System.out.println("Grade: A"); break;
case 8: System.out.println("Grade: B"); break;
case 7: System.out.println("Grade: C"); break;
case 6: System.out.println("Grade: D"); break;
default: System.out.println("Grade: F");
}
}
}
Output:
Input:
Enter marks: 75
Grade: C
Emergency Alert System
Write a program to handle emergency alerts using System.exit().
//emergency alert system
class EmergencyAlert
{
void main()
{
boolean emergency = true;
if (emergency)
{
System.out.println("Emergency detected! Terminating program.");
System.exit(0);
}
System.out.println("Program running normally.");
}
}
Output:
Emergency detected! Terminating program.
-
Sale
Voting poll app with MIT app Inventor Presentation
Compare to $5$0 -
Sale
Free Interactive Classroom Presentation for Kids for Grade 1 Math
Compare to $5$0 -
Sale
Create a To-Do List App in MIT App Inventor: A Step-by-Step Guide Presentation
Compare to $5$0 -
Sale
Free Conditional Statements in Python Worksheets
Compare to $5$0
Creating a Virtual Pet Game in Scratch Programming
Creating a Virtual Pet Game in Scratch Programming: A Step-by-Step Guide Are you ready to create you…
Crazy Scratch Project on Sprite Dance Party
Scratch Programing Project on Sprite Dance Party Scratch: The Basics Welcome to the second chapter o…
Mastering the concept of Loops in Java
A developer can control the flow of a program by executing a block of code repeatedly based on a con…
26 Free ICSE Board 10th Repeated JAVA PROGRAMS
Top ICSE Board 10th repeated JAVA Programs The ICSE Class 10 Computer Applications syllabus emphasiz…
Looks Block:Scratch Programming Flashcards
Instructions: Use these flashcards in the classroom for making the lessons interesting! Pick a stude…
Best ICSE 9th Mathematical Library Methods Notes
Key Concepts with Detailed Explanations and Examples – ICSE 9th Mathematical Library Methods T…
Find the perfect course
All of our courses are designed to help you learn the fundamentals and ace your Board Exams!