0% found this document useful (0 votes)
10 views15 pages

Computer Project

The document contains 10 Java programs written by a student named Srijan Das from Class 11, Section D with Roll Number 43. The programs cover topics such as calculating electricity bills based on units consumed, checking if a number is prime, checking if a number is a Krishnamurthy number, checking if words start and end with vowels, changing vowels in words to uppercase, finding the frequency of letters in a sentence, and more.

Uploaded by

srijandas120706
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)
10 views15 pages

Computer Project

The document contains 10 Java programs written by a student named Srijan Das from Class 11, Section D with Roll Number 43. The programs cover topics such as calculating electricity bills based on units consumed, checking if a number is prime, checking if a number is a Krishnamurthy number, checking if words start and end with vowels, changing vowels in words to uppercase, finding the frequency of letters in a sentence, and more.

Uploaded by

srijandas120706
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/ 15

COMPUTER PROJECT.

NAME: SRIJAN DAS.


CLASS: 11.
SECTION: D.
ROLL.NO: 43.
REG.NO: 2011/029.
SESSION: 2022-2023
PROGRAM :01

import java.util.*;

class Electricity Bill{

void accept()

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

System.out.println(“Enter the no. of units consumed”);

Units=sc.nextInt();}

Float clacBill()

if(units <=50)

billAmt=units*2.25f;

if(units>50 && units< 150)

billAmt= units*3.75f;

if(units > 150 && units<=300)

billAmt= units*5.25f;

if(units>300 && units<=550)

billAmt=units*7.75;

else

billAmt= units*9.50f;

void display(){

System.out.println(“The bill after consuming”+units+“ units is”+billAmt);

Public static void main(String args[])

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

ElectricityBill obj= new ElectricityBill();

obj.accept;

obj.calcBill();

obj.display();

}
PROGRAM :03

public class PrimeNumbers

private int x;

private int y;

void accept()

x=2;

y=100;

public void main(String args[])

PrimeNumbers obj= new PrimeNumbers();

obj.accept();

for(int i= x; i<= y; i++)

if(isPrime(i))

System.out.println(i);

}
}

static boolean isPrime (int n)

int count = 0;

if (n < 2)

return false;

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

if (n % i == 0)

return false;

return true;

PROGRAM :04

import java.util.*;

public class KrishnaMurthy

{ private int n;

void accept()

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

System.out.println("Enter any positve number:");

n = sc.nextInt();

if (isKrishna(n))

System.out.println(n + " is a krishnamurthy number");

else

System.out.println(n + "is not a krishnamurthy number");

} static int fact(int number)

{ int f = 1;

while (number != 0) {
f = f * number;

number--;

return f;

static boolean isKrishna(int number)

{ int sum = 0;

int tempNumber = number;

while (tempNumber != 0) {

sum = sum + fact(tempNumber % 10);

tempNumber = tempNumber / 10;

} if(sum == number)

return true;

else

return false;

} public static void main(String[] args)

{ KrishnaMurthy obj= new KrishnaMurthy();

obj.accept();

}
PROGRAM :06

import java.util.*;

public class SmithNum

{ private int n;

static int findSumPrimeFactors(int n)

{ int i=2, sum=0;

while(n>1)

{ if(n%i==0)

{ sum=sum+findSumOfDigit(i);

n=n/i;

else

{ do

{ i++;

while(!isKrishna(i));

return sum;

static int findSumOfDigit(int n)

{ int s=0;

while(n>0)

{ s=s+n%10;

n=n/10;

return s;

static boolean isKrishna(int k)

{
boolean b=true;

int d=2;

while(d<Math.sqrt(k))

if(k%d==0)

b=false;

d++;

return b;

void display()

int a = findSumOfDigit(n);

int b = findSumPrimeFactors(n);

if(a==b)

System.out.print("The given number is a smith number.");

else

System.out.print("The given number is not a smith number.");

public static void main(String args[])

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

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

int n=sc.nextInt();

SmithNum obj= new SmithNum();

obj.display();

}
PROGRAM :07

import java.util.*;

class Words

static String w[];

static int n;

void accept()

//importing scanner class

Scanner sc=new Scanner(System.in);

System.out.println("Enter no of words to be accepted");

n=sc.nextInt();

String w[]=new String[n];

//aceppting words

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

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

w[i]=sc.next();

int readWords(String a)

int c=0;

int l=a.length();

//counting number of words which start and end with vowel

if( a.charAt(0)=='A' || a.charAt(0)=='E' || a.charAt(0)=='I' || a.charAt(0)=='O' ||

a.charAt(0)=='U' || a.charAt(0)=='a' || a.charAt(0)=='e' || a.charAt(0)=='i' || a.charAt(0)=='o' ||

a.charAt(0)=='u' && a.charAt(l-1)=='A' || a.charAt(l-1)=='E' || a.charAt(l-1)=='I' || a.charAt(l-


1)=='O' ||
a.charAt(l-1)=='U' || a.charAt(l-1)=='a' || a.charAt(l-1)=='e' || a.charAt(l-1)=='i' || a.charAt(l-
1)=='o' ||

a.charAt(l-1)=='u' )

c=1;

return c;

boolean checkVowel(String s)

if(readWords(s)== 1)

return true;

else

return false;

void display()

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

if(checkVowel(w[i]=true))

System.out.println("The word"+w[i]+"starts and ends with a vowel");

public static void main(String args[])

Words ob=new Words();

ob.accept();

ob.readWords(w[n]);

ob.checkVowel(w[n]);
ob.display();

PROGRAM :09

import java.util.*;

public class ChangeVowels

{ private String w;

private String nw;

void readWord()

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

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

w= sc.nextLine();

change(w.toCharArray());

}
static void change(char []w)

{ int n= w.length;

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

if (w[i] == 'a' ||w[i] == 'e' || w[i] == 'i' || w[i] == 'o' || w[i] == 'u')

char nw= Character.toUpperCase(w[i]);

for(char nw: w)

System.out.println(nw);

public static void main(String args[])

ChangeVowels obj= new ChangeVowels();

obj.readWord();

}
PROGRAM :10

import java.util.*;

public class LetterFreq

{ private String sent;

void readSentence()

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

sent =sc.nextLine();

} void dispaly()

int i, j;

int[] freq = new int[sent.length()];

char string[] = sent.toCharArray();

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

freq[i] = 1;

for(j = i+1; j <sent.length(); j++) {

if(string[i] == string[j]) {

freq[i]++;

string[j] = '0';

System.out.println("Characters and their corresponding frequencies");

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

if(string[i] != ' ' && string[i] != '0')

System.out.println(string[i] + "-" + freq[i]);

} }

public static void main(String args[])

{ LetterFreq obj= new LetterFreq();

obj.display();

}}

You might also like