Вы находитесь на странице: 1из 9

ICSE PROJECT - 3

MISCELLANEOUS
PROGRAMS

NAME: MADHURIMA DATTA


CLASS - X

SECTION - B

ROLL NO - 12
SCHOOL: A.G. CHURCH ASANSOL

PROGRAM - 2

PROGRAM 2:

WAP to print the factorial of a number n using


the concept of Recursive function.

VARIABLE LISTING
Serial no

Variable name

Variable type

Variable description

fac

int

factorial calculator

int

number

PROGRAM
class factorial
{ int fac=1;
int perform(int n)
{if(n>0)
{ fac=fac*n;
perform(n-1); }
return fac;
}
}

PROGRAM - 5

PROGRAM 5:

Enter the name of a month and the day on which


the first day of the month starts . Print the
calendar of the month in the given format .
For example::
SUN

MON

2
3
9
10
16
17
23
24
30
31

TUE

WED

THRUS

11

12

13

14

15

18

19

20

21

22

25

26

27

28

29

FRI

SAT
1
8

VARIABLE LISTING

Serial no
1
2
3
4
5
6
7

Variable name
m
mn
i
k
nd
sp
yr

Variable type
String
String
int
int
int
int
int

Variable description
month name
day
loop variable
counter variable
month counter
day counter
year variable

PROGRAM
import java.io.*;
class calender
{String m,mn;int i,k,nd,sp=0,yr;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
void print()throws IOException
{
System.out.println("enter name of the month");
m=br.readLine();
m=m.trim();
m=m.toLowerCase();
if(m.equals("january")||m.equals("march")||m.equals("may")||m.equals("july")||
m.equals("august")||m.equals("october")||m.equals("december"))
nd=31;
if(m.equals("april")||m.equals("september")||m.equals("november"))
nd=30;
if(m.equals("february"))
{ System.out.println("Enter the year");
yr=Integer.parseInt(br.readLine());
if(yr%100==0)
{if(yr%400==0)
nd=29;
else
nd=28;
}
if(yr%4==0)
nd=29;
else
nd=28;

}
System.out.println(":Enter first day falls on");
mn=br.readLine();
mn=mn.toLowerCase();
if(mn.equals("monday"))
sp=1;
if(mn.equals("tuesday"))
sp=2;
if(mn.equals("wednesday"))
sp=3;
if(mn.equals("thursday"))
sp=4;
if(mn.equals("friday"))
sp=5;
if(mn.equals("saturday"))
sp=6;
if(mn.equals("sunday"))
sp=0;
System.out.println(" SUN \tMON \tTUES \tWED \tTHURS \tFRI \tSAT");

for(i=0;i<sp;i++)
System.out.print("\t");
k=sp;
for(i=1;i<=nd;i++)
{ System.out.print(i+"\t");
k++;
if(k==7)
{ k=0;System.out.println(" ");

}
}
}
}

OUTPUT
enter name of the month
february
Enter the year
2015
:Enter first day falls on
tuesday
SUN

MON TUES WED THURS FRI


1

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

SAT

PROGRAM - 6

Вам также может понравиться