Thursday, August 20, 2009

udaycoding

Description:-
We developed an algorithm, referring to tiles business.
By taking the business rule ( time factor ) into consideration, the algorithm had been developed. In this algorithm, for a particular area, the number of tiles and wastage of tiles are submitted for tiles of different types. Based on this, the choosing of tiles for particular area can be fairly identified.

The inputs, we taken in this algorithm are area of particular room, tiles of three types of different square feet. The intermediate outputs are, area occupied by the tiles of each type, left over area and the tile to be selected for the left over area.
The outputs will be number of tiles used for the particular room of area and wastage incurred.



Inputs and outputs:-
The inputs are
a) Area of the required room
b) Area of tiles of 3 types.
1) type1
2) type2
3) type3.

The outputs to be calculated
a) Number of tiles used.
b) Wastage of each tile.



Algorithm:-
౧.Among the tiles of each type, identify the type of tile which is bigger.
౨.Then by using the formulae, calculate the number of tiles used.
౩.Find out the area occupied by the each tile.
౪.By using the area of each tile and total area, calculate the left over area.
౫.Among the tiles, identify the tile which will be suitable, to fill the left over area.
౬.Calculate the wastage of each tile.





Business rules:-

1) Always the use the bigger tile to start.
2) Economical tile should always be selected among the tiles.


START

T1>T2


T2>T3
STOP
STOP
STOP


T1>T31. FLOW CHART FOR IDENTIFYING THE BIGGER TILE



























2. FLOW CHART FOR CALCULATING NUMBER OF TILES
START
Cal no. of tiles=
Area/ (tile size)
STOP


3. FLOW CHART FOR CALCULATING AREA OCCUPIED THE TILE.

START
Cal the area occupied the bigger tile=
No. of tiles*(size of tile)
STOP





4. CALCULATE THE LEFT OVER AREA.



START
Cal the leftover area=
Area – (area occupied the tile)
STOP


































5. TO IDENTIFY THE SUITABLE TILE FOR THE LEFT OVER AREA BY CAL. THE WASTAGE.




START
Choose the suitable tile, by cal. Wastage causes for each tile=
(Tile size*no. of tiles for particular area)-(left over area).
w1,w2,w3 respectively for each type.


w1>w3

w1>w2


w2>w3
STOP
STOP
STOP








TOTAL FLOW CHART:-


START
Calculate the number of tiles to be used, to fill the specific area =
Area/ (tile size).

Calculate the area occupied the tile each type, for the specific area=
No. of tiles*(size of tile)

Compute the left over area, by the formula=
Area – (area occupied the tile)


Identify the bigger tile, according to the business rule1.
Identify the suitable tile for left over area, by cal. the wastage caused by each type of tile.

Wastage of tiles of each type.
STOP
Program:-

#include
#include
void main()
{
float a,t[10],b,m,atile,lf,u[10],p,w,y[10];
int i,tile,j,q,s=2;
printf("enter the area of room");
fflush(stdout);
scanf("%f",&a);
printf("enter the tiles");
fflush(stdout);

/****************************************************
function name: negative
parameters : i,b
description : tiles are made non-negative in this.

****************************************************/
int negative( int b)
{
int t[100],i;
for(i=0;i<=2;i++) { scanf("%f",&b); if(b<0) b="-b;" m="t[0];" i="1;i<="2;i++)" q="1;q<=2;q++)" p="u[0];" lf="(a-atile);" atile="(tile*m);" m="t[i];" j="0;j<=2;j++)">u[q])
p=u[q];
} /* suitable tile is calculated and stored */
}
}
p=p+lf;
printf("%f\n",p);
w=p-lf; /* wastage is calculated */
printf(" wastage is..%f",w);
}






test cases:-

1)
area=100 tile1=3.5,tile2=2.5,tile3=1.5
enter the area of room 100
enter the tiles3.5
2.5
1.5
big is...3.5
no. of tiles is..28
area of tile is..98
left over is..2.
2.5
suitable tile is 2.5
wastage is..0.5

2)
area=1000 tile1=5,tile2=2,tile3=1
enter the area of room1000
enter the tiles5
2
1
big is...5
no. of tiles is..200
area of tile is..1000
left over is..0

wastage is..0







3)
area=100 tile1=0,tile2=0.5,tile3=0.7
enter the area of room100
enter the tiles0
0.5
0.7
big is...0.7
no. of tiles is..142
area of tile is..99.400002
left over is..0.599998
suitable tile is 0.7
wastage is..0.100002

4)
area=999.9 tile1=2.15 tile2=3.09 tile3=11.7
enter the area of room999.9
enter the tiles2.15
3.09
11.7
big is...11.7
no. of tiles is..85
area of tile is..994.5
left over is..5.400024
6.18
suitable tile is 3.09
wastage is..1.049976






5)
area=55000 tile1=36.2, tile2=59.6, tile3=42.3
enter the area of room55000
enter the tiles36.2
59.6
42.3
big is...59.599998
no. of tiles is..922
area of tile is..54951.199219
left over is..48.800781
59.599998
suitable tile is 59.599998
wastage is..10.799217

6) area=50 tile1=12.3 tile2=23.5,tile3=1.3
enter the area of room50
enter the tiles12.3
23.5
1.3
big is...23.5
no. of tiles is..2
area of tile is..47.
left over is..3.
3.9
suitable tile is 1.3
wastage is..0.9







7)
area=100000 tile1=5550.5, tile2=6650.6, tile3=9000.7
enter the area of room100000
enter the tiles5550.5
6650.6
9000.7
big is...9000.700195
no. of tiles is..11
area of tile is..99007.703125
left over is..992.296875
5550.5
suitable tile is 5550.5
wastage is..4558.203125

8)
area=10 tile1=23.5 tile2=1.3 tile3=0.5
enter the area of room10
enter the tiles23.5
1.3
0.5
big is...23.5
no. of tiles is..0
area of tile is..0
left over is..10
10.
suitable tile is 0.5
wastage is..0.







9)
Area=19636363,tile1=1.5,tile2=0.5,tile3=100000.55
enter the area of room19636363
enter the tiles1.5
0.5
100000.55
big is...100000.546875
no. of tiles is..196
area of tile is..19600108
left over is..36254.
36254.
suitable tile is 0.5
wastage is..0.

10)
Area=10,tile1=-1.5,tile2=-0.5,tile3=-0.05
enter the area of room10
enter the tiles-1.5
-0.5
-0.05
big is...1.5
no. of tiles is..6
area of tile is..9.
left over is..1
1.000000
suitable tile is -0.5
wastage is..0




pass cases:-

Area in sq.ft Tile1 in Tile2 in sq.ft

Tile3 in sq.ft
No. of tiles
Wastage in sq.ft
55000

36.2
59.6
42.3
28

0.5

1000

5

2

1

200

0

100

0

0.5

0.7

142

0.100002

999.9


2.15

3.09

11.7

85

1.049976
55000



36.2

59.6

42.

922

10.799217
50




12.3

23.5
1.3
2
0.9

100000

5550.5

6650.6

9000.7

11

4558.203125

10


23.5
1.3

0.5

0

0

19636363

1.5

0.5

100000.55

196

0

69.3
-9.3
2.3
6.3
11
0











Failure cases
Number
Area
Tile1
Tile2
Tile3
1
50
1.5
2.7
2.9
2
-100
3.5
3.6
1.5
3
100
0
0
0.0



1) If the area of tile is smaller than left over area.
2)

No comments:

Post a Comment