SELF PROFILE
NAME: Delisha Dutta
CLASS: IX
SECTION: Science
ROLL NO: 09
SUBJECT: Computer Applications
1
INDEX
SERIA TITLE PAG
L NO. E
NO.
1. INTRODUCTION 3
2. PROGRAM NO. 1 4-5
3. PROGRAM NO.2 6-7
4. PROGRAM NO. 3 8-9
5. PROGRAM NO. 4 9-10
6. PROGRAM NO. 5 10-11
7. PROGRAM NO. 6 11-12
2
Introduction:
Java is a popular programming language, created in 1995.
It is owned by Oracle, and more than 3 billion devices run Java.
It is used for:
Mobile applications (especially Android apps)
Desktop applications
Web applications
Web servers and application servers
Games
Database connection
And much, much more!
Uses of Java:
Java works on different platforms (Windows, Mac, Linux,
Raspberry Pi, etc.)
It is one of the most popular programming languages in the world
It has a large demand in the current job market
It is easy to learn and simple to use
It is open-source and free
It is secure, fast and powerful
It has huge community support (tens of millions of developers)
Java is an object-oriented language which gives a clear structure to
programs and allows code to be reused, lowering development costs
As Java is close to C++ and C#, it makes it easy for programmers to
switch to Java or vice versa
The six programming tasks are written in Java, a versatile and widely-
used programming language known for its portability, performance, and
robust ecosystem. Java's object-oriented principles, platform independence
through the Java Virtual Machine (JVM), and extensive standard libraries
make it a popular choice for various applications, from web development to
enterprise solutions and mobile applications. The language's strong typing
and automatic memory management contribute to its reliability and ease of
maintenance, making it a preferred option for many developers and
organizations worldwide.
3
Program no.: 1
Program Definition:
Write a program to compute and display the sum of the following series using switch case • S =
(1 + 2) / (1 * 2) + (1 + 2 + 3) / (1 * 2 * 3) + ----+ (1 + 2 + 3 + ----- + n ) / (1 * 2 * 3 * ----- * n) • S = 1
+ (x+2)/2! + (2x+3)/3! + (3x+4)/4! + ……… to n terms:
Algorithm:
Program code:
import java.util.*;
public class LICPolicy
{
public static void main (String[]args)
{
Scanner sc = new Scanner (System.in);
System.out.print("Enter the name of the policy holder: ");
String name = sc.nextLine();
System.out.print("Enter the sum assured: ");
double sumAssured = sc.nextDouble();
System.out.print("Enter the first annual premium: ");
double premium = sc. nextDouble();
double discount = 0.0;
double commission = 0.0;
if (sumAssured <= 100000)
{
discount = 0.05 * premium;
commission = 0.02 * sumAssured;
}
else if (sumAssured <= 200000)
{
discount = 0.08 * premium;
commission = 0.03 * sumAssured;
}
else if (sumAssured <= 500000)
{
discount = 0.10 * premium;
commission = 0.05 * sumAssured;
}
else
{
discount = 0.15 * premium;
commission = 0.075 * sumAssured;
}
System.out.println("Name of the policy holder:" + name);
System.out.println("Sum assured:" + sumAssured);
4
System.out.println("Premium:" + premium);
System.out.println("Discount on the first premium:" + discount);
System.out.println("Commission of the agent:" + commission);
}
}
Program no.: 2
Program Definition:
A company announces revised Dearness Allowance (DA) and Special Allowances (SA) for their
employees as per the tariff given below:
Basic Dearness Allowance (DA) Special Allowance (SA)
Up to ₹ 10,000 10% 5%
₹ 10,001 - ₹ 20,000 12% 8%
₹ 20,001 - ₹ 30,000 15% 10%
₹ 30,001 and above 20% 12%
Write a program to accept name and Basic Salary (BS) of an employee. Calculate and display
gross salary.
Gross Salary = Basic + Dearness Allowance + Special Allowance Print the information in the
given format:
Name Basic DA Special Allowance Gross Salary
xxx xxx xxx xxx xx
Algorithm:
1. Start.
2. Initialize Scanner for input.
3. Input name of the employee.
4. Input basic salary.
5. Initialize dearnessAllowance and specialAllowance to 0.
6. If basicSalary ≤ 10,000:
- dearnessAllowance = 0.10 * basicSalary
- specialAllowance = 0.05 * basicSalary
7. Else if basicSalary ≤ 20,000:
- dearnessAllowance = 0.12 * basicSalary
- specialAllowance = 0.08 * basicSalary
8. Else if basicSalary ≤ 30,000:
- dearnessAllowance = 0.15 * basicSalary
- specialAllowance = 0.10 * basicSalary
5
9. Else:
- dearnessAllowance = 0.20 * basicSalary
- specialAllowance = 0.12 * basicSalary
10. Calculate grossSalary = basicSalary + dearnessAllowance + specialAllowance.
11. Display name, basic salary, dearness allowance, special allowance, and gross salary.
12. End.
Program code:
import java.util.*;
public class SalaryCalculator
{
public static void main(String[] args) {
Scanner sc = new Scanner (System. in);
System.out.print("Enter the name of the employee: ");
String name = sc.nextLine();
System.out.print("Enter the basic salary:");
double basicSalary = sc.nextDouble();
double dearnessAllowance = 0.0;
double specialAllowance = 0.0;
if (basicSalary <= 10000)
{
dearnessAllowance = 0.10 * basicSalary;
specialAllowance = 0.05 * basicSalary;
}
else if (basicSalary <= 20000)
{
dearnessAllowance = 0.12 * basicSalary;
specialAllowance = 0.08 * basicSalary;
}
else if (basicSalary <= 30000)
{
dearnessAllowance = 0.15 * basicSalary;
specialAllowance = 0.10 * basicSalary;
}
else
{
dearnessAllowance = 0.20 * basicSalary;
specialAllowance = 0.12 * basicSalary;
}
double grossSalary = basicSalary + dearnessAllowance + specialAllowance;
System.out.println("Name: " + name);
System.out.println("Basic: " + basicSalary);
System.out.println("DA: " + dearnessAllowance);
System.out.println("Spl. Allowance: " + specialAllowance);
6
System.out.println("Gross Salary: " + grossSalary);
}
}
Program no.: 3
Program Definition:
Write a program in Java to accept a 3-digit number. Find the sum of square of first and third
digit. Also find the difference between the sum and the middle digit. Display all the 3 digits in a
tabular format.
Example:
Sample input:
489
Sum = 4^2 + 9^2
Difference = sum - 8
Sample output:
Hundred place value: 4
Ten place value: 8
One place value: 9
Algorithm:
1. Start.
2. Initialize Scanner for input.
3. Input a 3-digit number.
4. Extract digits:
- hundredPlace = number / 100
- tenPlace = (number / 10) % 10
- onePlace = number % 10
5. Calculate SumOfSquares = hundredPlace^2 + onePlace^2.
6. Calculate difference = SumOfSquares - tenPlace.
7. Display hundredPlace, tenPlace, onePlace, SumOfSquares, and difference.
8. End.
Program code:
import java.util.*;
public class DigitSumAndDifference
7
{
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
System.out.print("Enter a 3-digit number: ");
int number = sc.nextInt();
int hundredPlace = number / 100;
int tenPlace = (number / 10) % 10;
int onePlace = number % 10;
int sumOfSquares = (hundredPlace * hundredPlace) + (onePlace * onePlace);
int difference = sumOfSquares - tenPlace;
System.out.println("Hundred place value: " + hundredPlace);
System.out.println("Ten place value: " + tenPlace);
System.out.println("One place value: " + onePlace);
System.out.println("Sum of squares of hundred and one place digits: " +
sumOfSquares);
System.out.println("Difference between sum of squares and ten place digit: " +
difference);
}
}
Program no.: 4
Program Definition:
A tech number has even number of digits. If the number is split in two equal halves, then the
square of sum of these halves is equal to the number itself.
Write a program to accept a 4-digit number and check whether it is a tech number or not. Print
an error message if the input value is not a four-digit number.
Example:
Consider the number 3025
Square of sum of the halves of 3025
= (30 + 25) ^2
= (55) ^2
= 3025 is a tech number.
Algorithm:
1. Start.
2. Initialize Scanner for input.
3. Input a 4-digit number.
4. If number < 1000 or number > 9999:
- Display error message.
5. Else:
- Split number into halves:
- firstHalf = number / 100
- secondHalf = number % 100
- Calculate sumOfHalves = firstHalf + secondHalf.
- Calculate SquareOfSum = sumOfHalves^2.
- If SquareOfSum == number:
8
- Display number is a tech number.
- Else:
- Display number is not a tech number.
6. End.
Program code:
import java.util.*;
public class TechNumberChecker
{
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a 4-digit number: ");
int number = sc.nextInt();
if (number < 1000 || number > 9999) {
System.out.println("Error: The input value is not a four-digit number.");
}
else
{
int firstHalf = number / 100;
int secondHalf = number % 100;
int sumOfHalves = firstHalf + secondHalf;
int SquareOfSum = sumOfHalves * sumOfHalves;
if (SquareOfSum == number)
{
System.out.println(number + " is a tech number.");
}
else
{
System.out.println(number + " is not a tech number.");
}
}
}
}
Program no.: 5
Program Definition:
A shopkeeper sells two calculators for the same price. He earns 20% profit on one and suffers a
loss of 20% on the other. Write a program to find his total cost price of the calculators by taking
selling price as input.
9
Hint: CP = (SP / (1 + (profit / 100))) (when profit) CP = (SP / (1 - (loss / 100))) (when loss)
Algorithm:
1. Start.
2. Initialize Scanner for input.
3. Input selling price of one calculator.
4. Calculate costPriceProfit = sellingPrice / (1 + 0.20).
5. Calculate costPriceLoss = sellingPrice / (1 - 0.20).
6. Calculate totalCostPrice = costPriceProfit + costPriceLoss.
7. Display totalCostPrice.
8. End.
Program code:
import java.util.*;
public class CalculatorCostPrice
{
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the selling price of one calculator: ");
double sellingPrice = sc.nextDouble();
double costPriceProfit = sellingPrice / (1 + 0.20);
double costPriceLoss = sellingPrice / (1 - 0.20);
double totalCostPrice = costPriceProfit + costPriceLoss;
System.out.println("The total cost price of the two calculators is: " +
totalCostPrice);
}
}
Program no.: 6
Program Definition:
Write a program to enter your choice and perform the following tasks based on the option:
If choice is equal to 1 then to accept the time in second and display the time after converting
them into hours, minutes and seconds.
Sample Input: Time in seconds 5420
Sample Output: 1 Hour 30 Minutes 20 Seconds
If choice is equal to 2 then to check whether a given number is a 'Buzz Number or not.
A 'Buzz Number' is the number which ends with 7 or is divisible by 7.
Algorithm:
1. Start.
2. Initialize Scanner for input.
3. Display menu:
10
- 1. Convert time from seconds to hours, minutes, and seconds
- 2. Check if a number is a Buzz Number
4. Input choice.
5. If choice == 1:
- Input time in seconds.
- Calculate hours = totalSeconds / 3600.
- Calculate remainingSeconds = totalSeconds % 3600.
- Calculate minutes = remainingSeconds / 60.
- Calculate seconds = remainingSeconds % 60.
- Display hours, minutes, and seconds.
6. Else if choice == 2:
- Input number.
- If number % 10 == 7 or number % 7 == 0:
- Display number is a Buzz Number.
- Else:
- Display number is not a Buzz Number.
7. Else:
- Display invalid choice.
8. End.
Program code:
import java.util.*;
public class MenuDrivenProgram
{
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter your choice:");
int choice = sc.nextInt();
switch (choice)
{
case 1:
System.out.print("Enter time in seconds: ");
int totalSeconds = sc.nextInt();
int hours = totalSeconds / 3600;
int remainingSeconds = totalSeconds % 3600;
int minutes = remainingSeconds / 60;
int seconds = remainingSeconds % 60;
System.out.println(hours + " Hour " + minutes + " Minutes " + seconds + "
Seconds");
break;
case 2:
System.out.print("Enter a number: ");
int number = sc.nextInt();
if (number % 10 == 7 || number % 7 == 0)
{
System.out.println(number + " is a Buzz Number.");
}
11
else
{
System.out.println(number + " is not a Buzz Number.");
}
break;
default:
System.out.println("Invalid choice.");
break;
}
}
}
12