Friday, September 14, 2012

Computer Application Guess Paper On Programs For 2013 ICSE Students


Suggestions for ICSE students appearing in 2013. Please go through these programs and it may help you in your 2013 ICSE examination on computer application.

Program number 1: Define a class taximeter having the following description:
Data members/instance variables
int taxino - to store taxi number
String name - to store passenger's name
int km - to store number of kilometres travelled
Member functions:
taximeter() -- constructor to initialize taxino to 0, name to "" and km to 0.
input() - to store taxino, name, km
calculate() - to calculate bill for a customer according to given conditions
kilometers travelled(km) Rate/km
Less than 1 km: Rs 25
1 km to 6 km: Rs 20
Greater than 6 km and upto 12 km: Rs 18
Greater than 12 km and upto 18 km: Rs 15
Greater than 18 km:  Rs 10
display()- To display the details in the following format
Taxino Name Kilometres travelled Bill amount

 import java.io.*;
class taximeter
{
 int taxino,km;
 String name;
 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
 taximeter()
 {
  taxino=0;
  km=0;
  name="";
  }

public void input()throws Exception
{
 System.out.println("Enter the name:");
 name=br.readLine();
  System.out.println("Enter the taxi number:");
 taxino=Integer.parseInt(br.readLine());
  System.out.println("Enter the km travelled:");
 km=Integer.parseInt(br.readLine());
 }
 public void calculate()
 {
 System.out.println("Taxino Name    Kilometres travelled Bill amount ");
 System.out.print(taxino);
 System.out.print("   "+name);
 System.out.print("   "+km);
 if(km< 1)
System.out.print("  Rs. 25");
 else if(km>=1 && km<=6)
 System.out.print("  Rs."+(20*km));
 else if(km>6 && km<=12)
 System.out.print("  Rs."+(18*km));
 else if(km>12 && km<=18)
 System.out.print("  Rs."+(15*km));
 else if(km>18 )
 System.out.print("  Rs."+(10*km));
}

public static void main(String args[])throws Exception
{
taximeter ob=new taximeter();
ob.input();
ob.calculate();
}
 }

Program number 2: Write a menu driven program to find the sum of the following series depending on the
user choosing 1 or 2
1. S=1/4+1/8+1/12.........upto n terms
2. S=1/1!-2/2!+3/3!.......upto n terms
where ! stands for factorial of the number and the factorial value of a number is the
product of all integers from 1 to that number, e.g. 5! = 1 2 3 4 5.
(use switch-case).

import java.io.*;
class MenuDriven
{
 int n,choice;
 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
 public void input()throws Exception
{
 System.out.println("Enter The upper limit:");
n=Integer.parseInt(br.readLine());
System.out.println("Enter choice (1 or 2):");
choice=Integer.parseInt(br.readLine());
  switch(choice)
  {
   case 1:
   seriesFirst(n);
   break;
   case 2:
   seriesSecond(n);
   break;
   default:
   System.out.println("Wrong choice:");
   }
  }
 void seriesFirst(int n)
 {
  int i,x=4;
  double s=0;
  for(i=0;i< n;i++)
  {
   s=s+(double)1/x;
   x=x+4;
   }
   System.out.println("Result="+s);
   }
 void seriesSecond(int n)
 {
  int i;
  double s=0;
  int j,f;
  for(i=1;i<=n;i++)
  {
  f=1;
  for(j=2;j<=i;j++)
  f=f*j;
   s=s+(double)1/f;
   }
   System.out.println("Result="+s);
   }

public static void main(String args[])throws Exception
{
MenuDriven ob=new MenuDriven ();
ob.input();
}
 }

 Program number 3Write a program to accept a sentence and print only the first letter of each word of the sentence in capital letters separated by a full stop.
Example :
INPUT SENTENCE : “This is a cat”
OUTPUT : T.I.A.C.


import java.io.*;
class strr
{
 String str;
char ch;
int i, len;
 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
 public void input()throws Exception
{
 System.out.println("Enter The sentence:");
str=br.readLine();
len=str.length();
for(i=0;i< len;i++)
{
 ch=str.charAt(i);
if(i==0)
System.out.print(ch);
else if(ch==' ')
System.out.print("."+str.charAt(i+1));
}
System.out.print(".");
}
public static void main(String args[])throws Exception
{
strr ob=new strr ();
ob.input();
}
 }

Download eBook on BlueJ 

Program number 4: Write a program to create an array to store 10 integers and print the largest integer and the smallest integer in that array.


import java.io.*;
class MaxMin
{
int arr[]=new int[10];
int i,max,min;
 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
 public void input()throws Exception
{
for(i=0;i< 10;i++)
{
  System.out.println("Enter value:");
arr[i]=Integer.parseInt(br.readLine());
}
}
public void show()
{
 for(i=0;i< 10;i++)
{
  if(i==0)
  {
   max=arr[i];
   min=arr[i];
   }
   else if(arr[i]>max)
   {
   max=arr[i];
   }
   else if(arr[i]
   {
   min=arr[i];
   }
   }
   System.out.println("Maximum value="+max);
   System.out.println("Minimum value="+min);
}
public static void main(String args[])throws Exception
{
MaxMin ob=new MaxMin ();
ob.input();
ob.show();
}
 }

Program number 5: Write a program to store 10 names in an array. Arrange these in alphabetical order by sorting. Print the sorted list. Take single word names, all in capital letters,
e.g. SAMSON, AJAY, LUCY, etc.

import java.io.*;
class Record
{
String arr[]=new String[10];
int i,j;
String t;
 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
 public void input()throws Exception
{
for(i=0;i< 10;i++)
{
  System.out.println("Enter Name:");
arr[i]=br.readLine();
}
}
public void show()
{
 for(i=0;i< 10-1;i++)
{
 for(j=i+1;j< 10;j++)
{
 if(arr[i].compareTo(arr[j])>0)
 {
 t=arr[i];
 arr[i]=arr[j];
 arr[j]=t;
 }
 }
 }

 for(i=0;i< 10;i++)
System.out.println(arr[i]);
 }
public static void main(String args[])throws Exception
{
Record ob=new Record();
ob.input();
ob.show();
}
 }

3 comments:

  1. Replies
    1. Thanks for notifying the error. Actually for (i=0;i<n;i++) this controlled statement caused the error. In the program you found 'for(i=0;i' '<' was considered as HTML tag. Rectified.

      Delete
  2. This comment has been removed by a blog administrator.

    ReplyDelete

Subscribe via email

Enter your email address:

Delivered by FeedBurner