Search

Google
 

Wednesday, January 23, 2008

JAVA program for icse students

A library charges a fine for books returned late following are the charges for fine:--
First 5 Days:- 40 paise / day
6-10 days :- 60 paise /day
above 10 days:- 1 rupee /day

do with buffer reader..

import java.io.*;
class buff
{
void main()throws IOException
{
BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter no. of days");
int a;
a=Integer.parseInt(obj.readLine());
double ans=0;
if (a<=5)
ans=a*.4;
else if(a<=10)
ans= 2 + ((a-5)*.6);
else
ans= 2 + 3 + a-10;
System.out.println("Fine:"+ans);
}
}

Ask JAVA related questions at http://icse.fairtopic.com

No comments: