Wednesday, October 30, 2013

ISC 2014 Computer Application paper guess questions – Part I



Here are few guess questions with answers in Computer Application for students who will appear in ISC 2014.

In a function x and y are arguments greater than 0. Study the function and answer the following questions.

void func( int x, int y)
{
 if(x>1)
{
 if(x%y==0)
{
 System.out.print(y+" ");
func(x/y,y);
}
else
func(x,y+1);
}
}

What the function func (24,2) will return?
Ans: 2 2 2 3

What the function func (84,2) will return?
Ans: 2 2 3 7
What the function is doing?
The above function is displaying the factors of the first argument number starting from the second argument.

  
Here is a function which checks whether a number is magic number or not. It returns true if the number is magic number otherwise false.
What is magic number? Click here.

There are marks like ?1?, ?2? in some places of the code. Fill up the marks with actual code.

boolean isMagic( int n)
{
 int digit=0,s=n;
while(?1?)
{
 n=s;
s=0;
while(n>0)
{
 digit=?2?;
s=s+?3?;
?4?;
}
}
if(?5?)
return true;
else
return false;
}


?1?: while(s>9)
?2?: digit=n%10

?3?: s=s+digit

?4?: n=n/10

?5?: if(s==1)


A library issues a book on rental basis at a 2% charge on the cost price of the book per day. As per the library, a book can be kept for 7 days and if book is returned after 7 days, a fine will be charged for the extra days as per the chart given below :

Number of excess days       Fine per day

1 to 5                                    2.00
6 to 10                                  3.00
Above 10 days                    5.00


Design a class Library and another class Compute to perform the task.
The classes details are as given:
Class name : Library
Data members / instance variables :
Name, author : string variables to store name of book and authors name
p : Price of the book in decimals.

Member functions/methods :
Library(String n, String a, double np) : parameterised constructor to assign the parameters n to name, a to author and np to p.

void show( ) : displays the book details

Class Name : Compute
Data members/instance variables :
d : number of days taken in returning the book
r : to store the fine.
Member functions/methods:
Compute (........): parameterized constructor to assign values to data members of
both the classes.
void fine( ) : calculates the fine for the excess days.
void display( ) : displays the book details along with the number of days, fine and total amount to be paid as fine. The Amount is calculated as :( 2% of price of book * total no. of days) + fine



class Library
{
String name, author;
double p;
Library(String n, String a, double np)
{
  name=n;
author=a;
p=np;
}
void show( )
{
 System.out.println("Book Name="+name);
 System.out.println("Author Name="+author);
 System.out.println("Price of the book="+p);
}
}
class Compute extends Library
{
int d;
int r;
Compute( String n, String a, double np, int day)
{
 super(n,a,np);
d=day;

}
void fine( )
{
if(d<=7)
r=0;
else
{
r=d-7;
if(r>=1 && r<=5)
r=r*2;
else if(r>=6 && r<=10)
r=r*3;
else
r=r*5;
}
}
void display( )
{
double rr;
show();
 rr=(2.0/100)*p*d+r;
System.out.println("Book was kept for: "+d + " number of days.");
System.out.println("Fine amount="+r);
System.out.println("Total amount to be paid="+ rr);
}
public static void main(String args[])
{
 Compute ob=new Compute( "Java","Chakraborty", 123.00, 10);
 ob.fine();
ob.display();
}

}

Related Post:

Last Minute Suggession

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner