0% found this document useful (0 votes)
26 views34 pages

Computer Project 2024-2025

Uploaded by

vayunlakhmani4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views34 pages

Computer Project 2024-2025

Uploaded by

vayunlakhmani4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 34

ENGLISH PROJECT

2024-2025
Name- Vayun Lakhmani
Class- 10-B
ROLL NUMBER: 39
Subject- ENGLISH
MATHEMATICS
PROJECT
2024-2025
Name- Vayun Lakhmani
Class- 10-B
ROLL NUMBER: 39
Subject- MATHEMATICS

COMPUTER
APPLICATIONS
PROJECT 2024-
2025
Name- Vayun Lakhmani
Class- 10-B
ROLL NUMBER: 39
Subject- COMPUTER

HISTORY PROJECT
2024-2025
Name- Vayun Lakhmani
Class- 10-B
ROLL NUMBER: 39
Subject- History
HINDI PROJECT
2024-2025
Name- Vayun Lakhmani
Class- 10-B
ROLL NUMBER: 39
Subject- HINDI

COMPUTER
APPLICATIONS
PROJECT 2024-
2025
Name- Vayun Lakhmani
Class- 10-B
ROLL NUMBER: 39
Subject- COMPUTER
INDEX
S N N
. umbe r T o pic P age umbe r
1. 1
A ckn o wl e dgement
2. 1 2-3
P rog r am-
3. 2 4
P rog r am-
4. 3 5-6
P rog r am-
5. 4 7-8
P rog r am-
6. 5 9
P rog r am-
7. 10 -11
P rog r am- 6
8. 12
P rog r am- 7
9. 13 -1 4
P rog r am- 8
10. 15
P rog r am- 9
11. 10 16
P rog r am-
12. 17-2 0
P rog r am- 11
13. 12 21 -22
P rog r am-
14. 13 23 -2 4
P rog r am-
15. 14 25 -2 8
P rog r am-
16 15 29
P rog r am-
Acknowledgement
I would like to express my special thanks of gratitude to my
teacher, Mr. Neeraj Shrivastava , as well as our principal, Mr Gary
Dominic Everett , who gave me the golden opportunity to do this
wonderful project on the topic “Java Programs” which is a
wonderful topic and helped me in conveying my thoughts and
opinions to other readers and opened my mind to many new
things and I am grateful to them.
Secondly, I would also like to thank my parents and friends
who helped me a lot in finalizing this project within the limited
time frame.
Q.1 Write a program in Java to calculate total number of vowels
and consonants present in a given string
PROGRAM:
import java.util.*;
class vowel
{
public static void main(String args[])
{ int v= 0, c=0;
Scanner sc = new Scanner (System.in);
System.out.println ("Enter String "); String s =sc.next(); int l=
s.length(); // To find the number of characters present in the
string s= s.toUpperCase(); // converts string to upper case
s=s.trim(); for(int i= 0; i<l; i++)
{
char le= s.charAt(i); if (le=='A' || le=='E' || le=='I' || le== 'O' ||
le== 'U') // To check Number of vowels v++; else c++;
}
System.out.println ("Number of vowels present are=" +v);
System.out.println ("Number of consonants present are="+c);
}
}
P R
OGRAM:
import java.util.*;
class vertical
{
public static void main(String args[])
{
Scanner sc = new Scanner
(System.in);
System.out.println ("Enter
String "); String s
=sc.nextLine(); int l=
s.length(); s=s.trim(); s=
s.toUpperCase(); for (int i=0;
i<l; i++)
{
System.out.println (s.charAt(i));
}
}
{
public static void main (String args[])
{
Scanner sc = new Scanner (System.in);
System.out.println("Enter Marks"); // To input
marks int marks = sc.nextInt(); if( marks>=
75 && marks <=100 )
System.out.println("Grade=
A"); else if( marks>=60 &&
marks< 75) System.out.println
("Grade= B"); else
if(marks>=40 && marks<60)
System.out.println("Grade=
C"); else if (marks <40)
System.out.println ("Grade=
D"); else
System.out.println ("Invalid Marks");
}
}
Write a program
Q.4 in Java to generate a menu driven program to calculate the sum,
difference, product and average of any three given numbers.
PROGRAM:
import java.util.*;
class number
{
public static void main (String args[])
{
Scanner sc= new Scanner (System.in);
System.out.println ("Enter First
Number:"); double a = sc.nextDouble();
System.out.println ("Enter Second
Number"); double b= sc.nextDouble();
System.out.println ("Enter Third
Number"); double c =sc.nextDouble();
System.out.println ("Choice 1= Sum");
System.out.println ("Choice 2=
Difference");
System.out.println ("Choice 3= Product");
System.out.println ("Choice 4=
Average"); System.out.println
("Eneter Choice"); int ch
=sc.nextInt();
switch (ch)
{ case 1:
System.out.println
(a+b+c); break; case
2:
System.out.println (a-
b-c); break; case 3:
Write a program

System.out.println
(a*b*c); break; case 4:
System.out.println
( (a+b+c)/2); break;
default:
System.out.println("Invalid Number");

}
}

Q.5 in Java to verify whether the entered number is divisible by 8 or not


and display an appropriate message.
PROGRAM:
import java.util.*;
class divisible
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println( "Enter The Number To Be
Checked"); int n=sc.nextInt(); if (n % 8 ==0)
System.out.println("The Number is Divisible by
8"); else
System.out.println("Number is not Divisible by 8");
}

Q.6 Write a program using Java language to display the weekdays as per
the numbers entered from the keyboard. The entered numbers should be
between 1 and 7. Note: use switch–case statement only.
PROGRAM:
import java.util.*;
class days
{
public static void main (String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter your Choice
1-7"); int ch=sc.nextInt(); switch(ch)
{ case 1:
System.out.println
("Monday"); break; case 2:
System.out.println
("Tuesday"); break; case 3:
System.out.println
("Wednesday"); break; case
4:
Write a program

System.out.println
("Thursday"); break; case
5:
System.out.println("Frid
ay"); break; case 6:
System.out.println
("Saturday"); break; case
7:
System.out.println
("Sunday"); break;
default:
System.out.println("Invalid Number");
break;
{
public static void main(String
args[])
{ int i,j; for
(i=1;i<=5;i+
+)
{ for(j=1;j<=6-
i;j++)
{
System.out.print(6-i);
}
System.out.println ();
}
Q.8 Write a program using Java language to enter a string and check
whether it is a Palindrome or not. Note: Palindrome means characters read
from left to right and vice–versa are identical) PROGRAM:
import java.util.*;
class palindrome
{
public static void main (String args[])
{ String t="";
Scanner sc = new Scanner (System.in);
System.out.println ("Enter the
String"); String s =sc.next(); int
l= s.length(); s=
s.toUpperCase(); for (int i=l-1;
i>=0; i--)
{
t= t+ s.charAt(i);
}
t=t.trim(
);
if (s.compareTo(t)==0)
System.out.println ("Palindrome String
"); else
System.out.println ("Not a Palindrome
String:");
}
}
Q.9 Write a program using Java language to generate first ten numbers of a
Fibonacci series. Note: The Fibonacci series means the current number is the
sum of the previous two numbers except the first two numbers: Example: 0,
1, 1, 2, 3, 5....
PROGRAM:
class Fibonacci
{
public static void main(String args[])
{ int a=0, b=1;
System.out.print(a +" ");
System.out.print(b+"
"); for (int i=3;
i<=10; i++)
{
int c=a+b;
System.out.print(c+
" "); a=b; b=c;
}

starts at 3 and goes up


to 10, controlling the
iteration.
c int Stores the sum of a
and b, which is the
next Fibonacci number
in the sequence.
Q.10 Write a program using Java language to generate the factorial of a
given number up to n times. Example: The factorial of 5 is = 1*2*3*4*5
PROGRAM:
import java.util.*;
class factorial
{
public static void main (String args[])
{ int p=1;
Scanner sc =new Scanner
(System.in);
System.out.println("Enter the
Number"); int n=sc.nextInt(); for
(int i=1; i<=n; i++)
{
p= p*i;
}
System.out.println(p);

n int Stores the number


entered by the user for
which the factorial is to
be calculated.
i int Loop control variable
used to iterate from 1
to n to calculate the
factorial
Q.11 Define a class Student described as
below Data members/ instance variables:
Name, age, m1, m2, m3 (marks in 5 subjects), maximum,
average Member Methods:
(i) A parameterized constructor to initialize the data members
(ii) To accept the details of a student
(iii) To compute the average and the maximum out of five numbers
(iv) To display the name, age, marks in five subjects, maximum and
average Write a main method to create an object of a class and call the
above member methods PROGRAM:
import java.util.Scanner;

class Student {
// Instance variables String name; int age;
int m1, m2, m3, m4, m5; // Marks in five
subjects int maximum; double average;

// Constructor to initialize the data members


Student() {
name = "";
age = 0;
m1 = m2 = m3 = m4 =
m5 = 0; maximum = 0;
average = 0.0;
}
// Method to accept the details of a
student void acceptDetails() {
Scanner scanner = new
Scanner(System.in);

System.out.print("Enter the student's


name: "); name = scanner.nextLine();

System.out.print("Enter the student's age:


"); age = scanner.nextInt();

System.out.print("Enter marks for subject


1: "); m1 = scanner.nextInt();

System.out.print("Enter marks for subject


2: "); m2 = scanner.nextInt();

System.out.print("Enter marks for subject


3: "); m3 = scanner.nextInt();

System.out.print("Enter marks for subject


4: "); m4 = scanner.nextInt();
System.out.print("Enter marks for subject
5: "); m5 = scanner.nextInt();
}

// Method to compute the average and the maximum out of five


numbers void computeMaxAndAverage() { // Finding the
maximum marks maximum = m1; if (m2 > maximum)
maximum = m2; if (m3 > maximum) maximum = m3; if (m4 >
maximum) maximum = m4; if (m5 > maximum) maximum =
m5;

// Calculating the average


average = (m1 + m2 + m3 + m4 + m5) /
5.0;
}

// Method to display the name, age, marks, maximum, and


average void displayDetails() {
System.out.println("\nStudent Name: " +
name);
System.out.println("Age: " + age);
System.out.println("Marks in 5 subjects: " + m1 + ", " + m2 + ", " + m3
+ ", " + m4 + ", " + m5);
System.out.println("Maximum Marks: " + maximum);
System.out.println("Average Marks: " +
average);
}

// Main method
public static void main(String args[]) {
// Create an object of the Student class
Student student = new Student();

// Accept student details


student.acceptDetails();
// Compute maximum and average marks
student.computeMaxAndAverage();

// Display student details


student.displayDetails();
}
}

Variable Data Type Purpose of the


Variable
name String . Stores the student's
name.
age int Stores the student's age m1, m2, m3, m4, m5 int
Stores the student's
marks in five different
subjects.
maximum int Stores the highest mark
among the five subjects
average double Stores the calculated
average of the marks
from the five subjects.
scanner Scanner Used to take input from
the user
student Student Object of the Student
class created in the
main method to call
methods and store
data.
Q.12 Write a program to input 5 integer elements in an array and then check
the total number of odd and even numbers out of them and finally display
their count with an appropriate message.
PROGRAM:
import java .util.*;
class array
{
public static void main (String args[])
{ int odd= 0, even=0;
Scanner sc =new Scanner
(System.in);
System.out.println("Enter 5
Numbers"); int a[]= new int[5];
for (int i=0; i<5; i++)
{ a[i]=
sc.nextInt();
}
for (int i =0; i<5; i++)
{
if (a[i]%2== 0)
even++;

else
odd++;
}
System.out.println("Number of even
Numbers="+even);
System.out.println("Number of odd
Numbers="+odd);
}
}
Q.13 Write a program to create an array to store 3 integers and print the
largest integer and the smallest integer in that array.
PROGRAM:
import java.util.*;
class sort
{
public static void main (String args[])
{ int t=0;
Scanner sc = new
Scanner(System.in);
System.out.println ("Enter 3
Numbers"); int a[]= new int [3];
for (int i=0;i<3;i++)
{ a[i]=sc.nextInt(
); }
for (int i=0;i<2;i++)
{
for (int j=i+1; j<3; j++)
{ if (a[i]
>a[j])
{ t= a[i];
a[i]=
a[j];
a[j]=t;
}
}
}
System.out.println("largest Number="+a[2]);
System.out.println("Smallest
Number="+a[0]);
}

Q.14 Define a class employee having the following


description: Data members / instance variables:
a) int pan to store personal account number
b) String name to store name
c) double tax income to store annual taxable income
d) double tax to store tax that is calculated Member functions:
a) Input ( ) store the pan number, name, taxable income
b) Calc ( ) calculate tax for an employee
c) Display ( ) output details of an employee
Write a program using Java language to compute the tax according to the
given conditions and display the output as per given format:
Total Annual Taxable Income Tax Rate
1. Upto Rs. 1 lac No tax
2. From 1,00,001 – 1,50,000 10% of the income exceeding Rs. 1 lac
3. From 1,50,001 – 2,50,000 Rs. 5000+ 20% of the income exceeding Rs.
1,50,000
4. Above Rs. 2,50,000 Rs. 25,000 + 30% of the income exceeding Rs.
2,50,000
Output:

Pan Number Name Tax-income Tax


_________ _____ _________ ___
PROGRAM:
import java.util.Scanner;

class Employee {
// Data members / instance variables int
pan; // Personal Account Number
String name; // Employee name double
taxIncome; // Annual taxable income
double tax; // Calculated tax

// Method to store the PAN number, name, and taxable


income void input() {
Scanner scanner = new
Scanner(System.in);

System.out.print("Enter PAN Number:


"); pan = scanner.nextInt();
scanner.nextLine(); // To consume the newline character

System.out.print("Enter Employee Name:


"); name = scanner.nextLine();

System.out.print("Enter Taxable Income:


"); taxIncome = scanner.nextDouble();
}

// Method to calculate tax for the employee


void calc() { if
(taxIncome <=
100000) {
tax = 0;
} else if (taxIncome <=
150000) { tax = (taxIncome -
100000) * 0.10;
} else if (taxIncome <= 250000) { tax
= 5000 + (taxIncome - 150000) *
0.20;
} else { tax = 25000 + (taxIncome -
250000) * 0.30;
}
}
// Method to output the details of the
employee void display() {
System.out.println("\nPan Number\tName\tTaxable Income\tTax");
System.out.println(pan + "\t\t" + name + "\t" + taxIncome + "\t\t" +
tax);
}

// Main method to execute the program


public static void main(String args[]) {
// Create an instance of the Employee
class
Employee emp = new Employee();

// Input employee details


emp.input();

// Calculate the tax


emp.calc();

// Display the employee details


emp.display();
}
Q.15 Write a program using Java language to input a string and then
display it in the reverse order. Example: Input = “HELLO” Output =
“OLLEH” PROGRAM:
import java.util.*;
class reverse
{
public static void main (String args[])
{ String t="";
Scanner sc = new Scanner (System.in);
System.out.println ("Enter
String "); String s
=sc.nextLine(); int l=
s.length(); s=
s.toUpperCase(); for (int i=l-1;
i>=0; i--)
{
t= t+s.charAt(i); }

_____________________________________________________________________________
_

You might also like