Nothing Special   »   [go: up one dir, main page]

0% found this document useful (0 votes)
8 views46 pages

c p

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 46

ST.

ANN’S HIGH SCHOOL


(ISC)
PETBASHEERABAD

PRACTICAL RECORD
COMPUTER SCIENCE
2024-2025
Student Name: Shreyas

Class and Section: 10th/ C

Roll No: 41

Name & Signature of Internal Examiner ___________

Name & Signature of External Examiner __________


INDEX

S PAGE NUMBER PROGRAM


NO
3 INDEX
1. 4 Special Number
2. 5 Happy Number
3. 6 ISBN
4. 7 Series 1
5. 8 Series 2
6. 9 Magic Number
7. 10 Multiple Harshad Number
8. 11 ASCII
9. 12 Count
10. 13 Pattern
11. 14 Letters ASCII
12. 15 Max Min
13. 17 Average
14. 18 Linear Search
15. 19 Three Arrays
16. 21 Convert Case
17. 22 Surname
18. 23 Reverse
19. 24 Palindrome
20. 25 Happy Word
21. 27 Pattern 1
22. 27 Pattern 2
23. 28 Pattern 3
24. 29 Pattern 4
25. 30 Pattern 5
26. 31 Pattern 6
27. 32 Series
28. 33 Armstrong Number
29 34 Volume
30. 36 Increment
31. 37 Library
32. 39 Loan
33. 40 Mobike
34. 41 Temperature
35. 43 Cab Service
36. 45 Student
37. 46 Bill
38. 47
39. 48
40. 49
41. 50
42. 51
43. 52
44. 53

1. Special number

import java.util.*;

class Special_number

public static void main(String args[])

Scanner in=new Scanner(System.in);

int m,n,i,d,f=1,s=0;

System.out.print("Enter a no.");

n=in.nextInt();

m=n;

while(m!=0){

d=m%10;

for(i=1;i<=d;i++)

f*=i;

s+=f;f=1;

m=m/10;

}if(s==n){

System.out.println("The sum of factorial of digits is "+s);

System.out.println(n+" is special no.");

}else {

System.out.println("The sum of factorial of digits is "+s);


System.out.println(n+" is special no.");

2. Happy Number

import java.util.*;

class Happy_no

public static void main(String args[])

Scanner in=new Scanner(System.in);

System.out.println("Enter a number");

int n,s=0,d;

n=in.nextInt();

s=n;

do

n=s;s=0;

do

d=n%10;

s+=d*d;

n/=10;

}while(n>0);

if(sum==1)

System.out.println("Happy Number");
else

System.out.println("Happy Number");

3. ISBN

import java.util.*;

class ISBN

public static void main(String args[])

Scanner in=new Scanner(System.in);

int n,n1,i,r,sum=0,c=0;

System.out.println("Enter a 10 digit no.");

n=in.nextInt();

n1=n;

while(n1>0)

n1/=10;

c++;

}if(c<10 || c>10)

System.out.println("Illegal ISBN");

else{

for(i=10;i>=1;i--)

{
r=n%10;

sum+=r*i;

n/=10;

}if(sum==11)

System.out.println("A valid ISBN");

else

System.out.println("Not a valid ISBN");

4. Series1

import java.util.*;

class Series1

public static void main(String args[])

Scanner in=new Scanner(System.in);

System.out.println("Enter a number");

int n=in.nextInt();double s = 0.0;int x=1,f=1;

for(int i=1;i<=n;i++)

for(int j=1;j<=i;j++)

f*=j;

s+=(double)x/f;

}
System.out.println(s);

5. Series2

import java.util.*;

class Series2

public static void main(String args[])

Scanner in=new Scanner(System.in);

System.out.println("Enter two number");

int a=in.nextInt(); int n=in.nextInt();double s=0.0;int f=1;

for(int i=1;i<=n;i++)

for(int j=1;j<=i;j++)

f*=j;

s+=(double)a/f;

}System.out.println(s);

6. Magic Number

import java.util.*;

class Magic_no
{

public static void main(String args[])

Scanner in=new Scanner(System.in);

System.out.println("Enter a number");

int n=in.nextInt();int s=0,d,n1=n;

do

do

d=n%10;

n/=10; s+=d;

}while(n>0);

}while(s>9);

if(s==1)

System.out.println(n1+" is a Magic Number");

else

System.out.println("Not a Magic Number");

7. Multiple Harshad Number

import java.util.*;

class MHN

public static void main(String args[])

{
Scanner in=new Scanner(System.in);

System.out.println("Enter a number");

int h=in.nextInt();int h1=h,h2,s=0,s1=0,d,d1;

do

d=h%10;

s+=d;

}while(h>0);

if(h1%s==0)

h2=h1/s;

do

d1=h2%10;

s1+=d1;

}while(h2>0);

if(h2%s1==0)

System.out.println(h1+"is a Multiple Harshad Number");

else

System.out.println(h1+"is not a Multiple Harshad Number");

}else

System.out.println(h1+"is a Multiple Harshad Number");

8. ASCII

// To find the sum of ASCII codes of the characters


import java.util.*;

class ASCII

public static void main()

Scanner in=new Scanner(System.in);

char c;

int i,s=0;

System.out.println("Enter any 10 characters");

for(i=1;i<=10;i++)

c=in.next().charAt(0);

s=s+(int)c;

}System.out.println("Sum of the ASCII codes\t"+s);

9. To find the number of uppercase and lowercase characters

import java.util.*;

class Count
{

public static void main()

{ Scanner in=new Scanner(System.in);

char c; int i,n,nuc=0,nlc=0;

System.out.println("Enter the value of N");

n=in.nextInt();

System.out.println("Enter"+n+"characters");

for(i=1;i<=n;i++)

c=in.next().charAt(0);

if(Character.isUpperCase(c))

nuc++;

else

nlc++;

System.out.println("Number of uppercase characters\t"+nuc);

System.out.println("Number of lowercase characters\t"+nlc);

10. Pattern

// To generate the given pattern


class Pattern

public static void main()

int i,j;

for(i=65;i<=69;i++) {

for(j=65;j<=i;j++)

System.out.print((char)i);

System.out.println();

11. Letters and their ASCII

import java.util.Scanner;

public class LettersNUnicode

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.println("Enter 1 for A to Z with unicode");

System.out.println("Enter 2 for z to a with unicode");

System.out.print("Enter your choice: ");


int ch = in.nextInt();

switch (ch) {

case 1:

System.out.println("Letters" + "\t" + "Unicode");

for(int i = 65; i <= 90; i++)

System.out.println((char)i + "\t" + i);

break;

case 2:

System.out.println("Letters" + "\t" + "Unicode");

for (int i = 122; i >= 97; i--)

System.out.println((char)i + "\t" + i);

break;

default:

System.out.println("Incorrect Choice");

}
12. To display the greatest and the smallest numbers in SDA

import java.util.*;

public class Max_Min

public static void main(String args[])

Scanner in=new Scanner(System.in);

int i,min,max;

int m[]=new int[10];

for(i=0;i<10;i++) {

System.out.print("Enter the no. in the cell");

m[i]=in.nextInt();

}
max=m[0];

min=m[0];

for(i=0;i<10;i++)

if(m[i]>max)

max=m[i];

if(m[i]<min)

min=m[i];

System.out.println("The greatest of the array elements ="+max);

System.out.println("The smallest of the array elements ="+min);

13. To display the number of students with a aggregate marks

import java.util.*;

class Average

public static void main()

Scanner in = new Scanner(System.in);

int i,j,c1=0,c2=0;

int phy[]= new int[40];


int chem[] = new int[40];

int maths[] = new int[40];

for(i=0;i<40;i++)

System.out.println("Marks secured in Physics");

phy[i] = in.nextInt();

System.out.println("Marks secured in Chemistry");

chem[i] = in.nextInt();

System.out.println("Marks secured in Maths");

maths[i] = in.nextInt();

for(i=0;i<40;i++)

if((phy[i]+chem[i]+maths[i])/3.0 >= 80)

c1++;

if((phy[i]+chem[i]+maths[i])/3.0 <= 34)

c2++;

System.out.println("Number of students getting 80% and above\t"+c1);

System.out.println("Number of students getting 34% and below\t"+c2);

14. Linear Search

// To search a number in SDA by using Linear Search technique

import java.util.*;

public class Search

{
public static void main(String args[])

Scanner in=new Scanner(System.in);

int i,k=0,ns;

int m[]= new int[10];

for(i=0;i<10;i++)

System.out.print("Enter the number in the cell.");

m[i]=in.nextInt();

System.out.print("Enter the number to be searched :");

ns=in.nextInt();

for(i=0;i<10;i++)

if(m[i]==ns)

k = 1;

if (k==1)

System.out.println("The number is present");

else

System.out.println("The number is not present");

}
15. Three Arrays

import java.util.Scanner;

public class ThreeArrays

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

int P[] = new int[6];

int Q[] = new int[4];

int R[] = new int[10];

int i = 0;

System.out.println("Enter 6 elements of array P:");

for (i = 0; i < P.length; i++) {

P[i] = in.nextInt();

System.out.println("Enter 4 elements of array Q:");

for (i = 0; i < Q.length; i++) {

Q[i] = in.nextInt();

i = 0;

while(i < P.length) {

R[i] = P[i];
i++;

int j = 0;

while(j < Q.length) {

R[i++] = Q[j++];

System.out.println("Elements of Array R:");

for (i = 0; i < R.length; i++) {

System.out.print(R[i] + " ");

16. To convert the case of the string

import java.util.*;

public class Convert_Case

public static void main(String args[])

Scanner in=new Scanner(System.in);

int a,i,p;

String st,st1="";

char chr,chr1;
System.out.println("Enter your string:");

st=in.nextLine();

p=st.length();

for(a=0;a<p;a++)

chr=st.charAt(a);

if(chr>='a' &&chr<='z'){

chr1=Character.toUpperCase(chr);

st1=st1+chr1;

else if(chr>='A' &&chr<='Z')

chr1=Character.toLowerCase(chr);

st1=st1+chr1;

else

st1=st1+chr;

System.out.println("The new string after converting the case of each


letter");

System.out.println(st1);

17. To enter a full name and to print initials with surname

import java.util.*;

public class Surname


{

public static void main(String args[])

String st,sn,st1="",st2="";

int i,p;

char chr;

Scanner in=new Scanner(System.in);

System.out.println("Enter the full name");

st=in.nextLine(); //Accept full name

st=' '+st;

p=st.lastIndexOf(' '); //Obtain last blank position

sn=st.substring(p); //Extract the surname

for(i=0;i<p;i++) //Extract initial from each word

chr=st.charAt(i);

if(chr==' ')

st1=st1+st.charAt(i+1)+'.';

st2=st1+sn; //Concatenate initials and surname

System.out.println( "Initials with surname");

System.out.println(st2);

18. To reverse the letters of each word

import java.util.*;
public class Reverse

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.println("Enter a string:");

String str = in.nextLine();

int len = str.length();

String revStr = ""; //Empty String

StringTokenizer st = new StringTokenizer(str);

while (st.hasMoreTokens()) {

String word = st.nextToken();

int wordLen = word.length();

for (int i = wordLen - 1; i >= 0; i--) {

revStr += word.charAt(i);

revStr += " ";

System.out.println("String with words reversed:");

System.out.println(revStr);

19. Palindrome word

// To check whether a word is Palindrome or not

import java.util.*;

public class Palindrome

public static void main()


{

Scanner in=new Scanner(System.in);

System.out.println("Enter a word");

String word=in.next();String word1="";

int i,p;

char chr;

p=word.length();

for(i=p-1;i>=0;i--)

chr=word.charAt(i);

word1=word1+chr;

if(word.equals(word1))

System.out.println("Palindrome");

else

System.out.println("Not a Palindrome");

20. Happy Word

import java.util.Scanner;

public class HappyWord

private static boolean isHappyNumber(long num) {

long sum = 0;

long n = num;

do {
sum = 0;

while (n != 0) {

int d = (int)(n % 10);

sum += d * d;

n /= 10;

n = sum;

} while (sum > 6);

return (sum == 1);

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.println("Enter a word: ");

String word = in.next();

word = word.toUpperCase();

String wordValueStr = "";

int len = word.length();

for (int i = 0; i < len; i++) {

wordValueStr += String.valueOf(word.charAt(i) - 64);

long wordValue = Long.parseLong(wordValueStr);

boolean isHappy = isHappyNumber(wordValue);

if (isHappy)

System.out.println("A Happy Word");

else

System.out.println("Not a Happy Word");

}
21. Pattern1

public class Pattern1

public static void main(String args[]) {

String word = "ABCDE";

int len = word.length();

for (int i = 0; i < len; i++) {

for (int j = i; j < len; j++) {

char ch = word.charAt(j);

System.out.print(ch);

System.out.println();

22. Pattern2
public class Pattern2

public static void main(String args[]) {

char ch = 'A';

for (int i = 0; i < 5; i++) {

for (int j = 0; j <= i; j++) {

System.out.print(ch++);

System.out.println();

23. Pattern3

public class Pattern3

public static void main(String args[]) {

String word = "ABCDE";

int len = word.length();

for (int i = 0; i < len; i++) {

for (int j = 0; j < len - i; j++) {

System.out.print(word.charAt(j));

for (int k = 0; k < i; k++) {


System.out.print(word.charAt(k));

System.out.println();

24. Pattern4

import java.util.Scanner;

public class Pattern4

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Enter a word: ");

String word = in.nextLine();

int len = word.length();

for (int i = len - 1; i >= 0; i--) {

for (int j = 0; j <= i; j++) {

char ch = word.charAt(j);

System.out.print(ch);

System.out.println();

}
}

25. Pattern5

import java.util.Scanner;

public class Pattern5

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Enter a word: ");

String word = in.nextLine();

int len = word.length();

for (int i = len - 1; i >= 0; i--) {

for (int j = len - 1; j >= i; j--) {

char ch = word.charAt(i);

System.out.print(ch);

System.out.println();

}
26. Pattern6

import java.util.Scanner;

public class Pattern6

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Enter a word: ");

String word = in.nextLine();

int len = word.length();

for (int i = 0; i < len; i++) {

for (int j = i; j < len; j++) {

char ch = word.charAt(j);

System.out.print(ch);

System.out.println();

}
27. Series

//To find the sum of the series by using function

import java.util.*;

public class Series

int sum(int a)

int i,s=0;

for(i=1;i<a;i++)

s=s+(i*(i+1));

return(s);

public static void main(String args[])

Scanner in=new Scanner(System.in);

int p,n;

System.out.println("Enter the value of n");

n=in.nextInt();

Series ob= new Series();

p=ob.sum(n);

System.out.println("The sum of the series is "+p);

28. Armstrong Number

import java.util.Scanner;

public class ArmstrongNumber


{

public int armstrong(int n) {

int num = n, cubeSum = 0;

while (num > 0) {

int digit = num % 10;

cubeSum = cubeSum + (digit * digit * digit);

num /= 10;

if (cubeSum == n)

return 1;

else

return 0;

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Enter Number: ");

int num = in.nextInt();

ArmstrongNumber obj = new ArmstrongNumber();

int r = obj.armstrong(num);

if (r == 1)

System.out.println(num + " is an Armstrong number");

else

System.out.println(num + " is not an Armstrong number");

}
29. Volume

import java.util.*;

public class Volume

double volume(double r) {

double vol = (4 / 3.0) * (22 / 7.0) * r * r * r;

return vol;

double volume(double h, double r) {

double vol = (22 / 7.0) * r * r * h;

return vol;

double volume(double l, double b, double h) {

double vol = l * b * h;

return vol;

public static void main(String args[]) {

Volume obj = new Volume();

Scanner in=new Scanner(System.in);

System.out.println("Enter shape to measure volume:\n1 for Sphere\


n2 for Cylinder\n3 for Cuboid");

int x=in.nextInt();int r,l,b,h;

switch(x)

case 1:

System.out.println("Enter radius");

r=in.nextInt();

System.out.println("Sphere Volume = " + obj.volume(r));

break;
case 2:

System.out.println("Enter radius and height");

r=in.nextInt();

h=in.nextInt();

System.out.println("Cylinder Volume = " + obj.volume(5, 3.5));

break;

case 3:

System.out.println("Enter length, breadth and height");

l=in.nextInt();

b=in.nextInt();

b=in.nextInt();

System.out.println("Cuboid Volume = " + obj.volume(7.5, 3.5,


2));

break;

default:

System.out.println("Invalid input");

30. To calculate the increment of an employee

class Increment

String name;

int age;

double basic;
public void getdata(String n, int a, double b)

name=n;

age=a;

basic=b;

public void calculate()

double inc=0.0;

if(age>=56)

inc=basic*20.0/100.0;

if(age<56 && age>45)

inc=basic*15.0/100.0;

if(age<=45)

inc=basic*10.0/100.0;

basic=basic+inc;

public void display()

System.out.println("Name"+ "\t"+ "Age" +"\t" +"Updated Basic");

System.out.println(name+ "\t"+ age +"\t" + basic);

31. To display the details of library book

import java.util.*;
class Library

int acc_num;

String title;

String author;

Scanner in = new Scanner(System.in);

void input()

System.out.println("Enter accession number");

acc_num= in.nextInt();

System.out.println("Enter title of the book");

title= in.next();

System.out.println("Enter author name");

author= in.next();

void compute()

int n,fine;

System.out.println("Enter number of days the book is returned late");

n = in.nextInt();

fine = n*2;

System.out.println("Fine to be paid\t"+fine);

void display()

System.out.println("Accession Number\t"+"Title\t" +"Author");

System.out.println(acc_num+"\t"+title+"\t"+author);

public static void main(String args[])


{

Library ob=new Library();

ob.input();

ob.compute();

ob.display();

32. Loan

import java.util.Scanner;

public class Loan

int time;

double principal;

double rate;

double interest;

double amt;

public void getdata() {

Scanner in = new Scanner(System.in);

System.out.print("Enter principal: ");

principal = in.nextInt();

System.out.print("Enter time: ");


time = in.nextInt();

public void calculate() {

if (time <= 5)

rate = 15.0;

else if (time <= 10)

rate = 12.0;

else

rate = 10.0;

interest = (principal * rate * time) / 100.0;

amt = principal + interest;

public void display() {

System.out.println("Interest = " + interest);

System.out.println("Amount Payable = " + amt);

public static void main(String args[]) {

Loan obj = new Loan();

obj.getdata();

obj.calculate();

obj.display();

33. Mobike

import java.util.Scanner;
public class Mobike

int bno, phno, days, charge;

String name;

public void input() {

Scanner in = new Scanner(System.in);

System.out.print("Enter Customer Name: ");

name = in.nextLine();

System.out.print("Enter Customer Phone Number: ");

phno = in.nextInt();

System.out.print("Enter Bike Number: ");

bno = in.nextInt();

System.out.print("Enter Number of Days: ");

days = in.nextInt();

public void compute() {

if (days <= 5)

charge = days * 500;

else if (days <= 10)

charge = (5 * 500) + ((days - 5) * 400);

else

charge = (5 * 500) + (5 * 400) + ((days - 10) * 200);

public void display() {

System.out.println("Bike No.\tPhone No.\tName\tNo. of days \


tCharge");

System.out.println(bno + "\t" + phno + "\t" + name + "\t" + days

+ "\t" + charge);

}
public static void main(String args[]) {

Mobike obj = new Mobike();

obj.input();

obj.compute();

obj.display();

34. Temperature

// To calculate the maximum and minimum temperatures in Fahrenheit

import java.util.*;

public class Temperature

double max,min,f1,f2;

Temperature(double m, double n)

maxm:

min=n;

void compute()

f1=9*max/5+32;

f2=9*min/5+32;

void display()

{
System.out.println("The maximum temperature in Fahrenheit :"+ f1);

System.out.println("The minimum temperature in Fahrenheit :"+ 12);

public static void main(String args[])

Scanner in = new Scanner(System.in);

double t1,t2;

System.out.println("Enter maximum and minimum temperature in


Celsius:");

t1=in.nextDouble();

t2=in.nextDouble();

Temperature ob=new Temperature(t1,t2);

ob.compute();

ob.display();

35. Cab Service

//To calculate the bill

import java.util.*;

class Cabservice

String taxino,name;

int d,amt;

Cabservice()

taxino = "";
name = "";

d = 0; amt = 0;

void input()

Scanner in = new Scanner(System.in);

System.out.println("Enter taxi number: ");

taxino = in.nextLine();

System.out.println("Enter name of the passenger: ");

name = in.nextLine();

System.out.println("Enter distance travelled: ");

d = in.nextInt();

void calculate()

if (d <= 1)

amt=25;

if (d>1&& d <= 5 )

amt=d*30;

if (d>5&& d <= 10 )

amt=d*35;

if ( d >10&& d <= 20 )

amt=d*40;

if (d > 20)

amt=d*45;

void display()
{ System.out.println("Taxi No."+"\t" +"Name"+"\t\t"+"Distance(km)"+
"\t"+"Bill Amount(Rs.)");

System.out.println(taxino +"\t"+ name +"\t"+ d +"\t\t" +amt);

public static void main(String args[])

Cabservice ob= new Cabservice();

ob.input();

ob.calculate();

ob.display();

36. Student

import java.util.Scanner;

public class Student

String name;

int mm, scm, comp;

public Student(String n, int m, int sc, int c) {

name = n;

mm = m;

scm = sc;

comp = c;

private String check() {


String course = "Not Eligible";

double avg = (mm + scm + comp) / 3.0;

if (mm >= 90 && scm >= 90 && comp >= 90)

course = "Science with Computer";

else if (avg >= 90)

course = "Bio-Science";

else if (avg >= 80)

course = "Science with Hindi";

return course;

public void display() {

String eligibility = check();

System.out.println("Eligibility: " + eligibility);

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Enter Name: ");

String n = in.nextLine();

System.out.print("Enter Marks in Maths: ");

int maths = in.nextInt();

System.out.print("Enter Marks in Science: ");

int sci = in.nextInt();

System.out.print("Enter Marks in Computer: ");

int compSc = in.nextInt();

Student obj = new Student(n, maths, sci, compSc);

obj.display();

}
37. Bill

import java.util.Scanner;

public class Bill

private int bno;

private String name;

private int call;

private double amt;

public Bill() {

bno = 0;

name = "";

call = 0;

amt = 0.0;

public Bill(int bno, String name, int call) {

this.bno = bno;

this.name = name;

this.call = call;

public void calculate() {

double charge;

if (call <= 100)

charge = call * 0.6;

else if (call <= 200)

charge = 60 + ((call - 100) * 0.8);


else if (call <= 300)

charge = 60 + 80 + ((call - 200) * 1.2);

else

charge = 60 + 80 + 120 + ((call - 300) * 1.5);

amt = charge + 125;

public void display() {

System.out.println("Bill No: " + bno);

System.out.println("Name: " + name);

System.out.println("Calls: " + call);

System.out.println("Amount Payable: " + amt);

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Enter Name: ");

String custName = in.nextLine();

System.out.print("Enter Bill Number: ");

int billNum = in.nextInt();

System.out.print("Enter Calls: ");

int numCalls = in.nextInt();

Bill obj = new Bill(billNum, custName, numCalls);

obj.calculate();

obj.display();

You might also like