ISC COMPUTER SCIENCE PROJECT
Short Description
ISC 12TH COMPUTER SCIENCE PROJECT WITH OUTPUT...
Description
Page |1 QUESTION 1 : Program to accept the amount from the user and display the break-up in descending Order of denominations. (i.e. preference should be given to the highest denomination available) along with the total number of notes. The available denomination in the Bank are of rupees 1000, 500, 100, 50,20,10,5,2 and 1. Also print the amount in words according to the digits.
import java.io.*; class Bank { int rev=0,amount,dummy; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); public void intake() throws IOException { System.out.println("Enter the Amount:"); amount=Integer.parseInt(br.readLine()); if(amount >99999) { System.out.println("Invalid Amount..."); return; } dummy=amount; while(dummy >0) { rev=rev*10+dummy%10; dummy=dummy/10; } System.out.print("Amount in words :"); while(rev >0)
Page |2 { switch(rev%10) { case 0: System.out.print(" ZERO"); break; case 1: System.out.print(" ONE"); break; case 2: System.out.print(" TWO"); break; case 3: System.out.print(" THREE"); break; case 4: System.out.print(" FOUR"); break; case 5: System.out.print(" FIVE"); break; case 6: System.out.print(" SIX"); break; case 7: System.out.print(" SEVEN"); break;
Page |3 case 8: System.out.print(" EIGHT"); break; case 9: System.out.print(" NINE"); break; } rev=rev/10; } //SPLITTING INTO SMALLER DENOMINATIONS System.out.println("\nDENOMINATORS:\n"); rev=amount/1000; if(rev!=0) System.out.println("1000 X " + rev + " = " + rev*1000); amount=amount%1000; rev=amount/500; if(rev!=0) System.out.println("500 X " + rev + " = " + rev*500); amount=amount%500; rev=amount/100; if(rev!=0) System.out.println("100 X " + rev + " = " + rev*100); amount=amount%100; rev=amount/50; if(rev!=0) System.out.println("50 X " + rev + " = " + rev*50); amount=amount%50;
Page |4 rev=amount/20; if(rev!=0) System.out.println("20 X " + rev + " = " + rev*20); amount=amount%20; rev=amount/10; if(rev!=0) System.out.println("10 X " + rev + " = " + rev*10); amount=amount%10; rev=amount/5; if(rev!=0) System.out.println("5 X " + rev + " = " + rev*5); amount=amount%5; rev=amount/2; if(rev!=0) System.out.println("2 X " + rev + " = " + rev*2); amount=amount%2; rev=amount/1; if(rev!=0) System.out.println("1 X " + rev + " = " + rev*1); } }
Page |5 QUESTION 2 Program to accept number of telephone calls made and other details and calculates total amount and prints all relevant details. Amount calculation is as per the following table:
Number of calls
Cost
< 100
Rs. 500
101-200
Rs. 500 + Rs. 1 per extra calls over 100
201-300
Rs. 600 + Rs. 1.2 per extra calls over 200
> 300
Rs. 720 + Rs. 1.5 per extra calls over 300
class Telcall { String phno,name; int n; double amt;
Telcall(String ph,String na,int nc) { phno=ph; name=na; n=nc; amt=0.00; }
void compute()
Page |6 { //CALCULATING BILL BASED ON THE GIVEN SLAB SYSTEM if(n100&&n200&&n=60) { totm+=(int)(tots/60); tots=tots%60; } if(totm>=60)
Page |8 { toth+=(int)(totm/60); totm=totm%60; } System.out.println("TIME 1 : "+t1.hrs+" hrs "+t1.min+" min "+t1.sec+" sec"); System.out.println("TIME 2 : "+t2.hrs+" hrs "+t2.min+" min "+t2.sec+" sec"); System.out.println("\n\nFINAL TIME : "+toth+" hrs "+totm+" min "+tots+" sec"); } public static void main() throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter first time in order -> hr,min,sec"); int h1=Integer.parseInt(br.readLine()); int m1=Integer.parseInt(br.readLine()); int s1=Integer.parseInt(br.readLine()); System.out.println("Enter second time in order -> hr,min,sec"); int h2=Integer.parseInt(br.readLine()); int m2=Integer.parseInt(br.readLine()); int s2=Integer.parseInt(br.readLine()); Time_Calculate t1=new Time_Calculate(h1,m1,s1); Time_Calculate t2=new Time_Calculate(h2,m2,s2); add(t1,t2); } }
Page |9 QUESTION 4 : A String array of size ‘n’ where ‘n’ is greater than 1 and less than 10, stores single sentences (each sentence ends with a full stop) in each row of the array.Write a program to accept the size of the array. Display an appropriate message if the size is not satisfying the given condition. Define a string array of the inputted size and fill it with sentences row-wise. Change the sentence of the odd rows with an encryption of two characters ahead of the original character. Also change the sentence of the even rows by storing the sentence in reverse order. Display the encrypted sentences
import java.io.*; class Encryption { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String str[],s; int i,n; public void takeString() throws Exception { System.out.println("\nHow many sentences:"); n=Integer.parseInt(br.readLine()); if(n9) { System.out.println("\nINVALID ENTRY:"); return; } str=new String[n]; for(i=0;i< n;i++) { System.out.println("\nEnter sentence ( ends with full stop):"); s=br.readLine().trim(); if(s.charAt(s.length()-1)!='.')
P a g e | 10 { System.out.println("\nFull stop at the end is mandatory:"); i--; continue; } str[i]=s; } for(i=0;i< n;i++) { s=str[i]; if(i%2==0) encrypt(s); else reverse(s); } } public void encrypt(String s) { int i,len; char ch; String st=""; len=s.length(); for(i=0;i< len;i++) { ch=s.charAt(i); if((ch >=65 && ch< =90)||(ch >=97 && ch< =122)) {
P a g e | 11 ch=(char)(ch+2); if(ch >90 && ch< 97) { ch=(char)((64+ch-90)); } else if(ch >122) { ch=(char)((96+ch-122)); } } st=st+ch; } System.out.println(st); }
public void reverse(String s) { int i; String s1; s=s.trim(); s=s.substring(0,s.length()-1); while(true) { i=s.lastIndexOf(" "); if(i0) { sumfactors=sumfactors+j%10; j=j/10; } n=n/i; i--; } } } if(sum==sumfactors) System.out.println(no+ " is a smith number."); else System.out.println(no+ " is not a smith number."); } private int sumOfDigits(int n) { int s=0; while(n >0) { s=s+n%10; n=n/10; } return s; }
P a g e | 18
private boolean prime(int n) { int i; for(i=2;i< n;i++) { if(n%i==0) break; } if(i==n) return true; else return false; }
public static void main()throws Exception { SmithNum s1=new SmithNum (); s1.takeNumber(); } }
P a g e | 19 QUESTION 7: Write a program to convert a decimal number to binary octal and hexadecimal systems using Recursion Technique.
import java.io.*; class RecursiveConvert { static void bin(int n) { if(n==0) return ; else { bin(n/2); System.out.print(n%2); } } static void oct(int n) { if(n==0) return ; else { oct(n/8); System.out.print(n%8); } }
P a g e | 20 static void hex(int n) { // a[] IS AN ARRAY TO STORE THE EQUIVALENT HEXADECIMALS OF 1 TO 15 String a[]={"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"};
if(n==0) return ; else { hex(n/16); System.out.print(a[n%16]); } }
public static void main() throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the Number"); int n=Integer.parseInt(br.readLine()); System.out.println("Number in Binary system : "); bin(n); System.out.println("\nNumber in Octal system : "); oct(n); System.out.println("\nNumber in Hexadecimal system : "); hex(n); } }
P a g e | 21 QUESTION 8 : Program to input the details of a worker and calculate overtime wage and print net salary
class Worker { String name; double basic; Worker(String n,double b) { name=n; basic=b; } void display() { System.out.println("Name : "+name); System.out.println("Basic salary : Rs. "+basic); } } class Wages extends Worker
//USE OF INHERITANCE
{ int hrs; double rate,wage; Wages(String nm,double bas,int hr,double rt) { super(nm,bas); hrs=hr; rate=rt;
P a g e | 22 } double overtime() { return (hrs*rate); } void display() { super.display(); wage=overtime()+basic; System.out.println("Hours of work : "+hrs); System.out.println("Rate applicable : Rs. "+rate+"/hr"); System.out.println("\nTOTAL WAGE : Rs. "+wage); } } public class Worker_Inherit { public static void main() { Wages w=new Wages("Balu",5000.0,8,20.5); w.display(); } }
P a g e | 23 QUESTION 9 : Program to print all prime palindrome numbers in the given limit.
import java.io.*; class Prime_Palindrome { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int m,n; int var[]; Prime_Palindrome(int a,int b) { var=new int[3000]; if(a>3000) { System.out.println("OUT OF RANGE"); m=0; } else m=a; if(b>3000) { System.out.println("OUT OF RANGE"); n=0; } else n=b; }
P a g e | 24 boolean palindrome(int n) { int num=n,c=0; double sum=0.0,temp=n; while(num>0) { num=num/10; c++; } int r; num=n; while(num>0) { //EXTRACTING THE DIGITS AND REVERSING THE NUMBER r=num%10; sum=sum+(r*Math.pow(10,c-1)); num=num/10; c--; } if(sum==temp) return true; else return false; } boolean isPrime(int n) { int i,f=0;
P a g e | 25 for(i=1;i0) { digit++; no=no/10; } no=num; while(digit > 0) { rev=rev*10+no%10; no=no/10; digit--; }
// ‘rev’ HOLDS THE RIGHT PART AND ‘no’ HOLDS THE LEFT PART
rev=reverse(rev); if((rev+no)==x) { System.out.print(" "+x); c++; }
P a g e | 35 } private int reverse(int n) { int r=0; while(n > 0) { r=r*10+n%10; n=n/10; } return r; } }
P a g e | 36 QUESTION 13 : Write a program to accept details of a book, calculates and prints fine and total amount as : Total amount = (2 % of price x no. of days) + fine
import java.io.*; class Library { String name; String author; double price; Library(String nm,String auth,double pr) { name=nm; author=auth; price=pr; } void show() { System.out.println("Name of Book : "+name); System.out.println("Author of Book : "+author); System.out.println("Price of Book : "+price); } } class Compute extends Library {//USING INHERITANCE TO GET DETAILS FROM CLASS LIBRARY int d; double f,p1;
P a g e | 37 Compute(String n,String a,double p,int days) { super(n,a,p); d=days; p1=p; } void fine() { int excess=d-7; if(excess
View more...
Comments