From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 659/CH7/EX1.cs/Casestudy7_1.sce | 35 ++++++++++ 659/CH7/EX1.cs/Casestudy7_1_output.PNG | Bin 0 -> 11135 bytes 659/CH7/EX2.cs/Casestudy7_2.sce | 25 +++++++ 659/CH7/EX2.cs/Casestudy7_2_output.PNG | Bin 0 -> 12632 bytes 659/CH7/EX3.cs/casestudy7_3.sce | 46 +++++++++++++ 659/CH7/EX3.cs/casestudy7_3_output.PNG | Bin 0 -> 35477 bytes 659/CH7/EX4.cs/Casestudy7_4.sce | 122 +++++++++++++++++++++++++++++++++ 659/CH7/EX4.cs/Casestudy7_4_output.PNG | Bin 0 -> 87471 bytes 659/CH7/EX7.1/exm7_1.sce | 16 +++++ 659/CH7/EX7.1/exm7_1_output.PNG | Bin 0 -> 17741 bytes 659/CH7/EX7.2/exm7_2.sce | 42 ++++++++++++ 659/CH7/EX7.2/exm7_2_output.PNG | Bin 0 -> 18313 bytes 659/CH7/EX7.3/exm7_3.sce | 43 ++++++++++++ 659/CH7/EX7.3/exm7_3_output.PNG | Bin 0 -> 21547 bytes 659/CH7/EX7.4/exm7_4.sce | 18 +++++ 659/CH7/EX7.4/exm7_4_output.PNG | Bin 0 -> 9112 bytes 659/CH7/EX7.5/exm7_5.sce | 47 +++++++++++++ 659/CH7/EX7.5/exm7_5_output.PNG | Bin 0 -> 23415 bytes 18 files changed, 394 insertions(+) create mode 100755 659/CH7/EX1.cs/Casestudy7_1.sce create mode 100755 659/CH7/EX1.cs/Casestudy7_1_output.PNG create mode 100755 659/CH7/EX2.cs/Casestudy7_2.sce create mode 100755 659/CH7/EX2.cs/Casestudy7_2_output.PNG create mode 100755 659/CH7/EX3.cs/casestudy7_3.sce create mode 100755 659/CH7/EX3.cs/casestudy7_3_output.PNG create mode 100755 659/CH7/EX4.cs/Casestudy7_4.sce create mode 100755 659/CH7/EX4.cs/Casestudy7_4_output.PNG create mode 100755 659/CH7/EX7.1/exm7_1.sce create mode 100755 659/CH7/EX7.1/exm7_1_output.PNG create mode 100755 659/CH7/EX7.2/exm7_2.sce create mode 100755 659/CH7/EX7.2/exm7_2_output.PNG create mode 100755 659/CH7/EX7.3/exm7_3.sce create mode 100755 659/CH7/EX7.3/exm7_3_output.PNG create mode 100755 659/CH7/EX7.4/exm7_4.sce create mode 100755 659/CH7/EX7.4/exm7_4_output.PNG create mode 100755 659/CH7/EX7.5/exm7_5.sce create mode 100755 659/CH7/EX7.5/exm7_5_output.PNG (limited to '659/CH7') diff --git a/659/CH7/EX1.cs/Casestudy7_1.sce b/659/CH7/EX1.cs/Casestudy7_1.sce new file mode 100755 index 000000000..315946616 --- /dev/null +++ b/659/CH7/EX1.cs/Casestudy7_1.sce @@ -0,0 +1,35 @@ +// Case Study: Chapter 7, Page No:210 +// 1. Median of list of numbers + +N=10; +disp("Enter the number of items"); +n=scanf("%d"); +//Reading items into array a +printf("Input %d values[One at a time]\n",n); +for i=1:n + a(i)=scanf("%f"); +end +//Sorting begins +for i=1:n-1 + for j=1:n-i + if(a(j)<=a(j+1)) + t=a(j); + a(j)=a(j+1); + a(j+1)=t; + else + continue; + end + end +end //sorting ends +//Calculation of median +if(n/2==0) then + median1=(a(n/2)+a(n/2+1))/2.0; +else + median1=a(n/2+1); +end +//Printing +for i=1:n + printf("%f ",a(i)); +end +printf("\nMedian is %f\n",median1); + diff --git a/659/CH7/EX1.cs/Casestudy7_1_output.PNG b/659/CH7/EX1.cs/Casestudy7_1_output.PNG new file mode 100755 index 000000000..70c69cef1 Binary files /dev/null and b/659/CH7/EX1.cs/Casestudy7_1_output.PNG differ diff --git a/659/CH7/EX2.cs/Casestudy7_2.sce b/659/CH7/EX2.cs/Casestudy7_2.sce new file mode 100755 index 000000000..15d41a2fe --- /dev/null +++ b/659/CH7/EX2.cs/Casestudy7_2.sce @@ -0,0 +1,25 @@ +// Case Study: Chapter-7 +// 2.Calculation of standard deviation + +MAXSIZE=100; +sum1=0;n=0;sumsqr=0; +disp("Input values:input -1 to end"); +for i=1:MAXSIZE + value(i)=scanf("%f"); //Entering values in the array named value + if(value(i)==-1) + break; + end + sum1=sum1+value(i); + n=n+1; +end +mean1=sum1/n; //Computes mean +for i=1:n + deviation=value(i)-mean1; + sumsqr=sumsqr+deviation^2; +end +variance1=sumsqr/n; +stddeviation=sqrt(variance1); //Computes standard deviation +//Printing items,Mean and Standard deviation +printf("Number of items: %d\n",n); +printf("Mean: %f\n",mean1); +printf("Standard deviation: %f\n",stddeviation); \ No newline at end of file diff --git a/659/CH7/EX2.cs/Casestudy7_2_output.PNG b/659/CH7/EX2.cs/Casestudy7_2_output.PNG new file mode 100755 index 000000000..f25d31cec Binary files /dev/null and b/659/CH7/EX2.cs/Casestudy7_2_output.PNG differ diff --git a/659/CH7/EX3.cs/casestudy7_3.sce b/659/CH7/EX3.cs/casestudy7_3.sce new file mode 100755 index 000000000..6a67d724e --- /dev/null +++ b/659/CH7/EX3.cs/casestudy7_3.sce @@ -0,0 +1,46 @@ +// Case Study: Chapter-7 +// 3.Evaluating a Test + +STUDENTS=3; +ITEMS=5; +//Reading of correct answers +printf("Input key to the items\n"); +for i=1:ITEMS + key(i)=read(%io(1),1,1,'(a)'); //Read data using read function + // key(i)=scanf("%c"); It can be used to read data +end +//Evaluation begins + +for student=1:STUDENTS + //Reading students responses and counting correct ones + count=0; + printf("\nInput responses of student-%d",student); + for i=1:ITEMS + response(i)=scanf("%c"); + end + correct=zeros(1,ITEMS) +//Commented code can be used to replace above line i.e. correct=zeros(1,ITEMS) + //for i=1:ITEMS + // correct(i)=0; + //end + for i=1:ITEMS + if(response(i)==key(i)) then + count=count+1; + correct(i)=1; + end + end + //Printing of results + printf("Student-%d\n",student); + printf("Score is %d out of %d\n",count,ITEMS); + printf("Response to the items below are wrong\n"); + n=0; + for i=1:ITEMS + if(correct(i)==0) + printf(" %d",i); + n=n+1; + end + end + if(n==0) then + printf("NIL\n"); + end +end \ No newline at end of file diff --git a/659/CH7/EX3.cs/casestudy7_3_output.PNG b/659/CH7/EX3.cs/casestudy7_3_output.PNG new file mode 100755 index 000000000..27c105306 Binary files /dev/null and b/659/CH7/EX3.cs/casestudy7_3_output.PNG differ diff --git a/659/CH7/EX4.cs/Casestudy7_4.sce b/659/CH7/EX4.cs/Casestudy7_4.sce new file mode 100755 index 000000000..c5971f1ff --- /dev/null +++ b/659/CH7/EX4.cs/Casestudy7_4.sce @@ -0,0 +1,122 @@ +// Case Study: Chapter-7 +// 4.Production and sales analysis + +//Input Data +disp("Enter products manufactured week_wise"); +disp("M11,M12,--,M21,M22,--etc"); +for i=1:2 + for j=1:5 + M(i,j)=scanf("%d"); + end +end +disp("Enter products sold week_wise"); +disp("S11,S12,--,S21,S22,--etc"); +for i=1:2 + for j=1:5 + S(i,j)=scanf("%d"); + end +end +disp("Enter cost of each product"); +for j=1:5 + C(j)=scanf("%d"); +end +//Values matrices of production and sales +for i=1:2 + for j=1:5 + Mvalue(i,j)=M(i,j)*C(j); + Svalue(i,j)=S(i,j)*C(j); + end +end +//Total value of weekly production and sales +for i=1:2 + Mweek(i)=0; + Sweek(i)=0; + for j=1:5 + Mweek(i)=Mweek(i)+Mvalue(i,j); + Sweek(i)=Sweek(i)+Svalue(i,j); + end +end +//Monthly value of product_wise production and sales +for j=1:5 + Mproduct(j)=0; + Sproduct(j)=0; + for i=1:2 + Mproduct(j)=Mproduct(j)+Mvalue(i,j); + Sproduct(j)=Sproduct(j)+Svalue(i,j); + end +end +//Grand total of production and sales values +Mtotal=0;Stotal=0; +for i=1:2 + Mtotal=Mtotal+Mweek(i); + Stotal=Stotal+Sweek(i); +end + +//*********************************************** +//Selection and printing of information required +//*********************************************** +disp("Following is the list of things you request for"); +disp("Enter appropriate number and press return key"); + +disp("1.Value matrices of production and sales"); +disp("2.Total value of weekly production and sales"); +disp("3.Production_wise monthly value of production and sales"); +disp("4.Grand total value of production and sales"); +disp("5.Exit") + +number=0; +while(1) + //Begining of while loop + number=input("ENTER YOUR CHOICE:"); + if(number==5) then + disp("Good Bye"); + break; + end + select number + //Value Matices + case 1 then + disp("VALUE MATRIX OF PRODUCTION"); + for i=1:2 + printf("Week(%d)\t",i); + for j=1:5 + printf("%7d",Mvalue(i,j)); + end + printf("\n"); + end + disp("VALUE MATRIX OF SALES"); + for i=1:2 + printf("Week(%d)\t",i); + for j=1:5 + printf("%7d",Svalue(i,j)); + end + printf("\n"); + end + //Weekly Analysis + case 2 then + disp("TOTAL WEEKLY PRODUCTION AND SALES"); + disp(" PRODUCTION SALES"); + disp(" ---------- ------"); + for i=1:2 + printf("Week(%d)\t",i); + printf("%7d\t%9d\n",Mweek(i),Sweek(i)); + end + //Product wise Analysis + case 3 then + disp("PRODUCTWISE TOTAL PRODUCTION AND SALES"); + disp(" PRODUCTION SALES"); + disp(" ---------- ------"); + for i=1:5 + printf("Product(%d)\t",i); + printf("%7d\t%7d\n",Mproduct(i),Sproduct(i)); + end + //Grand Totals + case 4 then + disp("GRAND TOTAL OF PRODUCTION AND SALES"); + printf(" Total production = %d\n",Mtotal); + printf(" Total sales = %d\n",Stotal); + //Default + else + printf("Wrong choicce,select again\n"); + end //End of select +end //End of while +disp("Exit from the program"); \ No newline at end of file diff --git a/659/CH7/EX4.cs/Casestudy7_4_output.PNG b/659/CH7/EX4.cs/Casestudy7_4_output.PNG new file mode 100755 index 000000000..bd7cf1b60 Binary files /dev/null and b/659/CH7/EX4.cs/Casestudy7_4_output.PNG differ diff --git a/659/CH7/EX7.1/exm7_1.sce b/659/CH7/EX7.1/exm7_1.sce new file mode 100755 index 000000000..2618a6fbf --- /dev/null +++ b/659/CH7/EX7.1/exm7_1.sce @@ -0,0 +1,16 @@ +// Example:7.1 +//Write a program using single-subscripted variable to evaluate: +// sum of squares of 10 numbers.The values x1,x2,...are read from the terminal. + +//Reading values into array +disp("ENTER 10 REAL NUMBERS[Each in newline]"); +total=0; +for i=1:10 + x(i)=input(" "); + total=total+x(i)^2; //Computation of total +end +//Printing of x(i) values and total +for i=1:10 + printf("x(%2d) =%5.2f\n",i,x(i)); +end +printf("Total =%.2f",total); \ No newline at end of file diff --git a/659/CH7/EX7.1/exm7_1_output.PNG b/659/CH7/EX7.1/exm7_1_output.PNG new file mode 100755 index 000000000..bc97db5f2 Binary files /dev/null and b/659/CH7/EX7.1/exm7_1_output.PNG differ diff --git a/659/CH7/EX7.2/exm7_2.sce b/659/CH7/EX7.2/exm7_2.sce new file mode 100755 index 000000000..bb64796ac --- /dev/null +++ b/659/CH7/EX7.2/exm7_2.sce @@ -0,0 +1,42 @@ +// Example:7.2 +//Given below is the list of marks obtained by a class of 50 students in an +//annual examination. 43 65 51 27 79 11 56 61 82 09 25 36 07 49 55 63 74 81 49 +//37 40 49 16 75 87 91 33 24 58 78 65 56 76 67 45 54 36 63 12 21 73 49 51 19 39 +//49 68 93 85 59 +//Write a program to count the number of students belonging to each of +// following groups of marks:0-9,10-19,20-29,.......100. + +//This program computes for 10 students. We could compute for 50 students by +//changing MAXVAL=50. + +MAXVAL=10;COUNTER=11; +disp("Input Data[Marks of 10 students]"); +group1=zeros(1,11); +//Reading and counting +for i=1:MAXVAL + //Reading of values + value(i)=input(" "); + //Counting frequency of groups + a=int16((value(i)/10)); + if(a==0) then + group1(a+1)=group1(a+1)+1; + else + group1(a+1)=group1(a+1)+1; + end + +end +//Printing of frequency table +printf("Group Range Frequency\n"); +for i=0:COUNTER-1 + if(i==0) , + low=0; + else + low=i*10; + end + if(i==10), + high=100; + else + high=low+9; + end + printf("%2d %8d to %3d %5d\n",i+1,low,high,group1(i+1)); +end diff --git a/659/CH7/EX7.2/exm7_2_output.PNG b/659/CH7/EX7.2/exm7_2_output.PNG new file mode 100755 index 000000000..4b12a2e5f Binary files /dev/null and b/659/CH7/EX7.2/exm7_2_output.PNG differ diff --git a/659/CH7/EX7.3/exm7_3.sce b/659/CH7/EX7.3/exm7_3.sce new file mode 100755 index 000000000..e5e832b67 --- /dev/null +++ b/659/CH7/EX7.3/exm7_3.sce @@ -0,0 +1,43 @@ +// Example:7.3 +//Write a program using two dimensional array to compute print following +//information from the table of data discussed: +//(a)Total value of sales by each girl. +//(b)Total value of each item sold +//(c)Grand total of all sales of all items by all girls. + +MAXGIRLS=4;MAXITEMS=3; +frequency=zeros(1,5); +disp("Input data"); +//Reading values and computing girl_total +disp("Enter values,one at a time"); + +for i=1:MAXGIRLS + girl_total(i)=0; + for j=1:MAXITEMS + value(i,j)=scanf("%d"); + girl_total(i)=girl_total(i)+value(i,j); + end +end +//Computing item total +for j=1:MAXITEMS + item_total(j)=0; + for i=1:MAXGIRLS + item_total(j)=item_total(j)+value(i,j); + end +end +//Computing grand total +grand_total=0; +for i=1:MAXGIRLS + grand_total=grand_total+girl_total(i); +end +//Printing of result +disp("GIRLS TOTALS"); +for i=1:MAXGIRLS + printf("Salesgirl(%d)=%d\n",i,girl_total(i)); +end + +disp("ITEM TOTALS"); +for j=1:MAXITEMS + printf("Item(%d)=%d\n",j,item_total(j)); +end +printf("Grand Total=%d\n",grand_total); diff --git a/659/CH7/EX7.3/exm7_3_output.PNG b/659/CH7/EX7.3/exm7_3_output.PNG new file mode 100755 index 000000000..1d46a175a Binary files /dev/null and b/659/CH7/EX7.3/exm7_3_output.PNG differ diff --git a/659/CH7/EX7.4/exm7_4.sce b/659/CH7/EX7.4/exm7_4.sce new file mode 100755 index 000000000..857d99a74 --- /dev/null +++ b/659/CH7/EX7.4/exm7_4.sce @@ -0,0 +1,18 @@ +// Example:7.4 +//Write a program to compute and print a multiplication table for numbers 1 to 5 + +ROWS=5;COLUMNS=5; +disp("MULTIPLICATION TABLE"); +printf("*|") +for j=1:COLUMNS + printf("%4d",j); +end +disp("________________________"); +for i=1:ROWS + printf("%1d|",i); + for j=1:COLUMNS + product(i,j)=i*j; //Calculate the product + printf("%4d",product(i,j)); //Print the product + end + printf("\n"); +end \ No newline at end of file diff --git a/659/CH7/EX7.4/exm7_4_output.PNG b/659/CH7/EX7.4/exm7_4_output.PNG new file mode 100755 index 000000000..ebee535df Binary files /dev/null and b/659/CH7/EX7.4/exm7_4_output.PNG differ diff --git a/659/CH7/EX7.5/exm7_5.sce b/659/CH7/EX7.5/exm7_5.sce new file mode 100755 index 000000000..e1703c5bb --- /dev/null +++ b/659/CH7/EX7.5/exm7_5.sce @@ -0,0 +1,47 @@ +// Example:7.5 +//A survey to know the popularity of four cars(Ambassador,fait,Dolphin and +//Maruti) was conducted in four cities(Bombay,Calcutta,Delhi and Madras). +//Each person surveyed was asked to give his city and type of car he was using. +//Write a program to prouce a table showing the popularity of various cars in +//four cities. + +frequency=zeros(5,5); +printf("For each person,enter the city code[B,C,D,M]\n"); +printf("followed by the car code[1,2,3,4].\n"); +printf("Enter the letter X 0(zero)to indicate end.\n"); + +//Tabulation begins +for i=1:99 + [n,city,car]=mscanf("%c %d"); + if(city=='X') then + break; + end + select city + case 'B' then frequency(1,car)=frequency(1,car)+1; + case 'C' then frequency(2,car)=frequency(2,car)+1; + case 'D' then frequency(3,car)=frequency(3,car)+1; + case 'M' then frequency(4,car)=frequency(4,car)+1; + end + +end + +//Tabulation completed and Printing begins +disp(" POPULATORY TABLE"); +printf("______________________________________________\n"); +printf("City Ambasseador fait Dolphin Maruti\n"); +printf("______________________________________________\n"); + +for i=1:4 + select i + case 1 then printf(" Bombay "); + case 2 then printf(" Calcutta"); + case 3 then printf(" Delhi "); + case 4 then printf(" Madras "); + end + for j=1:4 + printf("%8d",frequency(i,j)); + end + printf("\n"); +end +printf("______________________________________________"); +// Printing ends \ No newline at end of file diff --git a/659/CH7/EX7.5/exm7_5_output.PNG b/659/CH7/EX7.5/exm7_5_output.PNG new file mode 100755 index 000000000..856dc06d8 Binary files /dev/null and b/659/CH7/EX7.5/exm7_5_output.PNG differ -- cgit