21. Update the FrequencyDistributionQuantitative class defined...
Shared By : Your Name (College - Place ) Show/Hide Program
Share this program...
Send it to gtumca@gmail.com
with your Name - College name..
and share what you want ... at same mail id...
Thanx in advance...
Be connected...
D_i_Z
22. Create a class called Stem and Leaf, which should have a...
Shared By : Shreyank Vyas ( Atmiya College Rajkot) Show/Hide Program
package Gtu;
import java.io.*;
import java.util.Formatter;
/*
this is stamp_leaf.csv file data that we have create manually.....(SV)
12,112,72,69,97,107,73,126,82,92,115,95,84,68,100,92,128,104,108,76,141,119,98,85,76,118,132,96,91,81,113,115,94,86,127,134,100,102,80,98,106,106,73,124,83,92,81,106,75,95,119
*/
class StemAndLeaf {
int data[]=null;
StemAndLeaf() {
data=new int[50];
}
void loadFromCSV(FileInputStream fin) throws IOException {
int ch,i,j=0,num=0;
do {
i = fin.read();
if(i != -1) {
if(i == 44) {
data[j]=num;
j++;
num=0;
} else {
num*=10;
ch=i-48;
num+=ch;
}
}
} while(i != -1);
data[j]=num;
fin.close();
}
void display() {
Formatter f;
boolean flag=true;
int stm[]=new int[9]; // 9 means no of stamp value
int lf[][]=new int[9][11]; // 11 means no leaf in per stamp
int k=0,m=0;
for(int i=0;i<stm.length;i++) {
stm[i]=-1;
for(int j=0;j<lf[i].length;j++)
lf[i][j]=-1;
}
for(int i=0;i<data.length;i++) {
flag=true;
for(int j=0;j<stm.length;j++) {
if((data[i]/10) == stm[j]) {
flag=false;
break;
}
}
if(flag && data[i]!=0) {
stm[k]=(data[i]/10);
k++;
}
}
for(int i=0;i<stm.length-1;i++) {
for(int j=i+1;j<stm.length;j++) {
if(stm[i]>stm[j]) {
int temp=stm[i];
stm[i]=stm[j];
stm[j]=temp;
}
}
}
for(k=0;k<stm.length;k++) {
m=0;
for(int i=0;i<data.length;i++) {
if(stm[k]==(data[i]/10) && data[i]!=0 && stm[k]!=-1) {
lf[k][m]=data[i]%10;
m++;
}
}
}
for(k=0;k<stm.length;k++) {
for(int i=0;i<lf[k].length-1;i++) {
for(int j=i+1;j<lf[k].length;j++) {
if(lf[k][i]>lf[k][j]) {
int temp=lf[k][i];
lf[k][i]=lf[k][j];
lf[k][j]=temp;
}
}
}
}
for(k=0;k<stm.length;k++) {
f=new Formatter();
f.format("%2d",stm[k]);
System.out.print(f);
System.out.print(" I ");
for(int i=0;i<lf[k].length;i++)
if(lf[k][i]!=-1)
System.out.print(lf[k][i]+" ");
System.out.println();
}
}
}
class Prog22 {
public static void main(String args[]) throws IOException {
StemAndLeaf sl=new StemAndLeaf();
FileInputStream fin;
try {
fin = new FileInputStream("stamp_leaf.csv");
}
catch(FileNotFoundException e) {
System.out.println("File Not Found");
return;
}
sl.loadFromCSV(fin);
sl.display();
}
}
23. Create a class called Pie Canvas, which subclasses from...
Shared By : Your Name (College - Place ) Show/Hide Program
Share this program...
Send it to gtumca@gmail.com
with your Name - College name..
and share what you want ... at same mail id...
Thanx in advance...
Be connected...
D_i_Z
24. Create a class called Statistical Data, which has capability...
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
class StatisticalData
{
int v1[],v2[];
String v1name,v2name;
public StatisticalData()
{
v1name=new String("str1");
v2name=new String();
v1=new int[5];
v2=new int[5];
v2name="str2";
}
public void get()
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int i;
System.out.println("Enter First variable name and its values: ");
try{
v1name = br.readLine();
for(i=0;i<5;i++)
{
v1[i]=Integer.parseInt(br.readLine());
}
System.out.println("Enter Second variable name and its values: ");
v2name = br.readLine();
for(i=0;i<5;i++)
{
v2[i]=Integer.parseInt(br.readLine());
}
}
catch(IOException e)
{
System.out.println("Error while Reading from console");
}
}
public void correl_coeff()
{
double d,m1=0,m2=0,tatb=0,sab,ta2=0,tb2=0,sa,sb,cor_coef;
int i;
System.out.printf("%s: ",v1name);
for(i=0;i<5;i++)
{
System.out.printf("%d ",v1[i]);
}
System.out.println();
System.out.printf("%s: ",v2name);
for(i=0;i<5;i++)
{
System.out.printf("%d ",v2[i]);
m1=m1+v1[i];
m2=m2+v2[i];
}
System.out.println();
m1=m1/5;
m2=m2/5;
for(i=0;i<5;i++)
{
tatb=tatb+(v1[i]-m1)*(v2[i]-m2);
ta2=ta2+(v1[i]-m1)*(v1[i]-m1);
tb2=tb2+(v2[i]-m2)*(v2[i]-m2);
}
sab=tatb/4;
sa=ta2/5;
sb=tb2/5;
sa=Math.sqrt(sa);
sb=Math.sqrt(sb);
cor_coef=sab/sa*sb;
System.out.println("correlation co-efficient: " + cor_coef);
}
}
class P24
{
public static void main(String args[])
{
StatisticalData x=new StatisticalData();
x.get();
x.correl_coeff();
}
}
25. Simple random sampling uses a sample of size n from...
Shared By : Your Name (College - Place ) Show/Hide Program
Share this program...
Send it to gtumca@gmail.com
with your Name - College name..
and share what you want ... at same mail id...
Thanx in advance...
Be connected...
D_i_Z
26. Dasher is an information-efficient text-entry interface,...
Shared By : Your Name (College - Place ) Show/Hide Program
Share this program...
Send it to gtumca@gmail.com
with your Name - College name..
and share what you want ... at same mail id...
Thanx in advance...
Be connected...
D_i_Z
27. Write a class in Java to plot a Histogram for the data...
Shared By : Your Name (College - Place ) Show/Hide Program
Share this program...
Send it to gtumca@gmail.com
with your Name - College name..
and share what you want ... at same mail id...
Thanx in advance...
Be connected...
D_i_Z
28. Write a class in Java to plot a Scatter diagram for the...
Shared By : Your Name (College - Place ) Show/Hide Program
Share this program...
Send it to gtumca@gmail.com
with your Name - College name..
and share what you want ... at same mail id...
Thanx in advance...
Be connected...
D_i_Z
29. Define a class which implements the Table Model...
Shared By : Prof.Swati Patel (SSIT Gandhinagar) Show/Hide Program
//Prof.Swati Patel(SSIT Gandhinagar)
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class StatisticalData
{
int v1[],v2[];
String v1name,v2name;
public StatisticalData()
{
v1=new int[5];
v2=new int[5];
v2name="str2";
}
public void get()
{
int i;
for(i=0;i<5;i++)
{
v1[i]=i*2;
}
for(i=0;i<5;i++)
{
v2[i]=i*5;
}
}
public int correl_coeff(int x)
{
int i;
for(i=0;i<5;i++)
{
return v1[x];
} return 0;
}
public double correl_ans()
{
double d,m1=0,m2=0,tatb=0,sab,ta2=0,tb2=0,sa,sb,cor_coef;
int i;
for(i=0;i<5;i++)
{
m1=m1+v1[i];
m2=m2+v2[i];
}
m1=m1/5;
m2=m2/5;
for(i=0;i<5;i++)
{
tatb=tatb+(v1[i]-m1)*(v2[i]-m2);
ta2=ta2+(v1[i]-m1)*(v1[i]-m1);
tb2=tb2+(v2[i]-m2)*(v2[i]-m2);
}
sab=tatb/4;
sa=ta2/5;
sb=tb2/5;
sa=Math.sqrt(sa);
sb=Math.sqrt(sb);
cor_coef=sab/sa*sb;
return cor_coef;
}
public int correl_coeff2(int x)
{
for(int i=0;i<5;i++)
{
return v2[x];
} return 0;
}
}
public class prog28{
public static void main(String[] args){
int i;
StatisticalData x=new StatisticalData();
x.get();
Integer temp;
Double ans;
JFrame jf = new JFrame("Inventory");
Container c = jf.getContentPane();
Object[] colnames = {"H1","H2"};
Object[][] data=new Object[10][10];
for(i=0;i<5;i++)
{
temp=x.correl_coeff(i);
data[i][0]=temp;
}
for(i=0;i<5;i++)
{
temp=x.correl_coeff2(i);
data[i][1]=temp;
}
ans=x.correl_ans();
data[i][0]="Correlation";
data[i][1]=ans;
jf.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}
});
JTable jt = new JTable(data, colnames);
JScrollPane scrollableTable = new JScrollPane(jt);
c.add(scrollableTable);
jf.setSize(500, 150);
jf.setVisible(true);
}
}
//gtu-mca.blogspot.com
30. Create an applet which has a Text Field to accept a...
Shared By : Unknown... Show/Hide Program