download link:http://www.megaupload.com/?d=1CUR491F
12. Update the classes Triangle and Rectangle, to throw an exception...
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
13. Define a class called Polygon Manager, which manages a...
import java.io.*; interface input { BufferedReader br =new BufferedReader(new InputStreamReader(System.in)); } abstract class polygon_manager implements input { int x[]; int i; int size; int y[]; polygon_manager() { } polygon_manager(int xy) { x=new int[xy]; y=new int[xy]; size=xy; i=0; } abstract void display(); } class triangle extends polygon_manager { triangle() { } triangle(int xy) { super(xy); } void add()throws IOException { System.out.println("\nEnter the Three Co-Ordinates :"); for(i=0;i<3;i++)>"); x[i]=Integer.parseInt(br.readLine()); y[i]=Integer.parseInt(br.readLine()); } } void display() { System.out.print("\n\tTriangle :- {"); for(i=0;i<3;i++) i="0;i<4;i++)">"); x[i]=Integer.parseInt(br.readLine()); y[i]=Integer.parseInt(br.readLine()); } } void display() { System.out.print("\n\tRectangle :- {"); for(i=0;i<4;i++) i="0;i<5;i++)">"); x[i]=Integer.parseInt(br.readLine()); y[i]=Integer.parseInt(br.readLine()); } } void display() { System.out.print("\n\tPantagon :- {"); for(i=0;i<5;i++) i="0;i<6;i++)">"); x[i]=Integer.parseInt(br.readLine()); y[i]=Integer.parseInt(br.readLine()); } } void display() { System.out.print("\n\tHexagon :- {"); for(i=0;i<6;i++) i="0;i<8;i++)">"); x[i]=Integer.parseInt(br.readLine()); System.out.println(); y[i]=Integer.parseInt(br.readLine()); } } void display() { System.out.print("\n\tOctagon :- {"); for(i=0;i<8;i++) len="0,j=" choice ="-">"); ch=Integer.parseInt(br.readLine()); switch(ch) { case 1: menuformat(); ch=Integer.parseInt(br.readLine()); switch(ch) { case 1: triangle t=new triangle(3); t.add(); p[len]=t; len++; break; case 2: rectangle r=new rectangle(4); r.add(); p[len]=r; len++; break; case 3: pantagon pa=new pantagon(5); pa.add(); p[len]=pa; len++; break; case 4: hexagon h=new hexagon(6); h.add(); p[len]=h; len++; break; case 5: octagon o=new octagon(8); o.add(); p[len]=o; len++; break; case 6: break; default : System.out.println("\nPlz Enter 1 To 6 ................."); break; } break; case 2 : if(len<1) j="0;j"); pos=Integer.parseInt(br.readLine()); if(pos"); pos=Integer.parseInt(br.readLine()); if(pos"); pos=Integer.parseInt(br.readLine()); if(pos"); pos=Integer.parseInt(br.readLine()); if(pos"); pos=Integer.parseInt(br.readLine()); if(pos"); } }
14. Define a class called Statistical Data which manages...
Shared By : Jani Anand (SRIMCA-Bardoli) Show/Hide Program
Download link: http://www.megaupload.com/?d=Q6F6X7XZ
Shared By : Sonam Patel(SRIMCA-Tarsadi ) Show/Hide Program
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; class StatisticalData { int v[],N; String vname; public StatisticalData() { N=0; vname=""; } public void setData() { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int i; System.out.printf("How many values You want to Enter? "); try{ N=Integer.parseInt(br.readLine()); } catch(IOException e) { System.out.println("Error while Reading from console"); } v=new int[N]; System.out.printf("Enter variable Name and its values: "); try{ vname = br.readLine(); for(i=0;i temp[j+1]) { x=temp[j]; temp[j]=temp[j+1]; temp[j+1]=x; } } } if(N%2 == 0) { x=N/2; m=temp[x]; x--; m=m+temp[x]; m=m/2; } else { x=N/2; System.out.println("IND: " + x); m=temp[x]; } return m; } public double Mode() { double M,x,m; M=Median(); x=Mean(); m=3*M-2*x; return m; } public double Variance() { double var=0,m; int i; m=Mean(); for(i=0;i temp[j+1]) { x=temp[j]; temp[j]=temp[j+1]; temp[j+1]=x; } } } if(p==100) return temp[N-1]; else { P=p; n=N; n=P*n/100; P=Math.ceil(n); if(P-n > 0) { i=(int)P; P=temp[i-1]; } else { i=(int)P; P=temp[i]+temp[i-1]; P=P/2; } return P; } } } class P14 { public static void main(String args[]) { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StatisticalData s=new StatisticalData(); int ch=10,ch1=1,p=-1; double result,Q3; s.setData(); do { do { System.out.println("1. Set Data"); System.out.println("2. Mean"); System.out.println("3. Median"); System.out.println("4. Mode"); System.out.println("5. Variance"); System.out.println("6. Standard Deviation"); System.out.println("7. Percentile (between 0 - 100)"); System.out.println("8. Quartile (between 1 - 3)"); System.out.println("9. Interquartile Range"); System.out.println("10. Exit"); System.out.print("Enter Your Choice: "); try{ ch=Integer.parseInt(br.readLine()); } catch(IOException e) { System.out.println("Error while Reading from console"); } }while(ch<1>10); switch(ch) { case 1: s.setData(); break; case 2: result=s.Mean(); System.out.println("Mean: " + result); break; case 3: result=s.Median(); System.out.println("Median: " + result); break; case 4: result=s.Mode(); System.out.println("Mode: " + result); break; case 5: result=s.Variance(); System.out.println("Variance: " + result); break; case 6: result=s.StdDev(); System.out.println("Standard Deviation: " + result); break; case 7: do { System.out.print("Which Percentile you want to calculate? "); try{ p=Integer.parseInt(br.readLine()); } catch(IOException e) { System.out.println("Error while Reading from console"); } }while(p<0>100); result=s.Percentile(p); System.out.println("Percentile: " + result); break; case 8: do { System.out.println("1. First "); System.out.println("2. Second "); System.out.println("3. Third "); System.out.print("Enter Your Choice: "); try{ ch1=Integer.parseInt(br.readLine()); } catch(IOException e) { System.out.println("Error while Reading from console"); } }while(ch1<1>3); switch(ch1) { case 1: result=s.Percentile(25); System.out.println("First Quartile: " + result); break; case 2: result=s.Percentile(50); System.out.println("Second Quartile: " + result); break; case 3: result=s.Percentile(75); System.out.println("Third Quartile: " + result); } break; case 9: Q3=s.Percentile(75); result=s.Percentile(25); result=Q3-result; System.out.println("Inter Quartile Range: " + result); } }while(ch != 10); } }
Shared By : Hardikgiri Goswami (Indus Institute of Technology ) Show/Hide Program
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package javaapplication4; import java.io.*; class p14 { public static void main(String args[]) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StatisticalData s=new StatisticalData(); int ch=1; while(ch!=0) { /*float f1=2234.34534427f; System.out.format("%1$.2f",f1);*/ System.out.println("\n\n\n\n\n\nMain Menu"); System.out.println("1. Insert Mark"); System.out.println("2. Mean"); System.out.println("3. Median"); System.out.println("4. Mode"); System.out.println("5. Variance"); System.out.println("6. Standard Deviation"); System.out.println("7. Specified Percentile"); System.out.println("8. Specified Quarlite"); System.out.println("9. Interquartile Range"); System.out.println("0. Exit"); System.out.print("Enter your choice :"); try { ch=Integer.parseInt(br.readLine()); } catch(NumberFormatException nfx) { System.out.println("You can not enter the string.... OR can not leave it blank....."); ch=13; } if(s.get_size()==0 && ch!=1) { if(ch>10) { System.out.println("System can't recognize your choice, re-enter your selection...."); } else if( ch != 0) { System.out.println("Enter the mark of student first....."); } } else { switch(ch) { case 1: String ch1="Y"; while(ch1.compareToIgnoreCase("N")!=0) { if(ch1.equalsIgnoreCase("Y") || ch1.equalsIgnoreCase("N")) { s.add(); } else { System.out.println("Enter Y (for Yes) \nEnter N (for No)... Otherwise System can't recognize...."); } System.out.print("Want to add more ? (Y/N) :"); ch1=br.readLine(); } break; case 2: System.out.println("Mean : "+s.mean()); break; case 3: System.out.println("Median : "+s.median()); break; case 4: System.out.println("Mode : "+s.mode()); break; case 5: System.out.println("Variance : "+s.variance()); break; case 6: System.out.println("Standard Deviation : "+s.standard_deviation()); break; case 7: System.out.println("Enter value for Specified Percentile (0-100) :"); int p=Integer.parseInt(br.readLine()); if( p > 100 || p < q="Integer.parseInt(br.readLine());"> 3 || q < br="new" marks="new" n="0;" n="=" temp="Integer.parseInt(br.readLine());">100 || temp<0) sum="0;" i="0;itemp) { temp=count[k]; temp1=k; System.out.println(temp1); } } if(temp1==-1) { //f m=(2*median())+(3*mean()); } else { m=marks[temp1]; } return m; } float variance() { float mean=mean(); float sum=0; for(int i=0;imarks[j]) { int temp=marks[i]; marks[i]=marks[j]; marks[j]=temp; } } } } void display() { for(int i=0;i
15. Update the class Statistical Data, and define a method...
Shared By : Prof.Swati Patel (SSIT Gandhinagar) Show/Hide Program
import java.util.*; import java.io.*; class StatisticalData { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int marks[]; int n; StatisticalData(){ marks=new int[60]; n=0; } void add()throws IOException{ if(n==60) { System.out.println("There is 60 student in the class..."); System.out.println("You can't enter any more marks....."); } else{ System.out.print("Enter Mark of Student : "+(n+1)+" : "); try{ int temp=Integer.parseInt(br.readLine()); if(temp>100 || temp<0) sum="0;" i="0;itemp) { temp=count[k]; temp1=k; } } System.out.println("Mode is/are ....."); if(temp1==-1) { m=(3.0f*median())-(2.0f*mean()); System.out.println(m); } else{ for(int i=0;i100 || t<0) temp2="">=48 && asc<=57) { str[0]=(char)asc; String temp3=new String(str); temp2=temp2.concat(temp3); } } } System.out.println("Your meaningfull data from CSV file found as follow...."); for (int j=0;jmarks[j]) { int temp=marks[i]; marks[i]=marks[j]; marks[j]=temp; } } } } void display(){ System.out.println("\n Your Data is .....\n"); for(int i=0;i11) { System.out.println("System can't recognize your choice,re-enter your selection...."); } else if( ch != 0 ) { System.out.println("Enter the mark of student first....."); } } else{ switch(ch) { case 1: String ch1="Y"; while(ch1.compareToIgnoreCase("N")!=0){ if(ch1.equalsIgnoreCase("Y") || ch1.equalsIgnoreCase("N")){ s.add(); } else{ System.out.println("Enter Y (for Yes) \nEnter N (for No)... Otherwise System can't recognize...."); } System.out.print("Want to add more ? (Y/N) :"); ch1=br.readLine(); } break; case 2: System.out.println("Mean : "+s.mean()); break; case 3: System.out.println("Median : "+s.median()); break; case 4: s.mode(); break; case 5: System.out.println("Variance : "+s.variance()); break; case 6: System.out.println("Standard Deviation : "+s.standard_deviation()); break; case 7: int flag=0; while(flag==0) { try{ System.out.print("Enter value for Specified Percentile (0-100) :"); int p=Integer.parseInt(br.readLine()); if( p > 100 || p < flag="1;" flag="0;" flag="=" q="Integer.parseInt(br.readLine());"> 3 || q < flag="1;" flag="0;" path="" flag="=" path="br.readLine();" ext="path.substring(path.length()-4);" istr="new" flag="1;" flag="0;" path="" flag="=" ext="" path="br.readLine();" ext="path.substring(path.length()-4);" f="new" flag="1;">
import java.util.*; import java.io.*; class p15{ public static void main(String args[]) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StatisticalData s=new StatisticalData(); int ch=1; while(ch!=0){ System.out.println("\n\n\n\n\n\nMain Menu"); System.out.println("01. Insert Mark"); System.out.println("02. Mean"); System.out.println("03. Median"); System.out.println("04. Mode"); System.out.println("05. Variance"); System.out.println("06. Standard Deviation"); System.out.println("07. Specified Percentile"); System.out.println("08. Specified Quarlite"); System.out.println("09. Interquartile Range"); System.out.println("10. Load Data from CSV file ( using Input Stream )"); System.out.println("11. Load Data from CSV file ( using File )"); System.out.println("0. Exit"); System.out.print("Enter your choice :"); try{ ch=Integer.parseInt(br.readLine()); } catch(NumberFormatException nfx) { System.out.println("You can not enter the string.... OR can not leave it blank....."); ch=13; } if(s.get_size()==0 && ch!=1 && ch!=10 && ch!=11) { if(ch>11) { System.out.println("System can't recognize your choice,re-enter your selection...."); } else if( ch != 0 ) { System.out.println("Enter the mark of student first....."); } } else{ switch(ch) { case 1: String ch1="Y"; while(ch1.compareToIgnoreCase("N")!=0){ if(ch1.equalsIgnoreCase("Y") || ch1.equalsIgnoreCase("N")){ s.add(); } else{ System.out.println("Enter Y (for Yes) \nEnter N (for No)... Otherwise System can't recognize...."); } System.out.print("Want to add more ? (Y/N) :"); ch1=br.readLine(); } break; case 2: System.out.println("Mean : "+s.mean()); break; case 3: System.out.println("Median : "+s.median()); break; case 4: s.mode(); break; case 5: System.out.println("Variance : "+s.variance()); break; case 6: System.out.println("Standard Deviation : "+s.standard_deviation()); break; case 7: int flag=0; while(flag==0) { try{ System.out.print("Enter value for Specified Percentile (0-100) :"); int p=Integer.parseInt(br.readLine()); if( p > 100 || p < flag="1;" flag="0;" flag="=" q="Integer.parseInt(br.readLine());"> 3 || q < flag="1;" flag="0;" path="" flag="=" path="br.readLine();" ext="path.substring(path.length()-4);" istr="new" flag="1;" flag="0;" path="" flag="=" ext="" path="br.readLine();" ext="path.substring(path.length()-4);" f="new" flag="1;" br="new" marks="new" n="0;" n="=" temp="Integer.parseInt(br.readLine());">100 || temp<0) sum="0;" i="0;itemp) { temp=count[k]; temp1=k; } } System.out.println("Mode is/are ....."); if(temp1==-1) { m=(3.0f*median())-(2.0f*mean()); System.out.println(m); } else{ for(int i=0;i100 || t<0) temp2="">=48 && asc<=57) { str[0]=(char)asc; String temp3=new String(str); temp2=temp2.concat(temp3); } } } System.out.println("Your meaningfull data from CSV file found as follow...."); for (int j=0;jmarks[j]) { int temp=marks[i]; marks[i]=marks[j]; marks[j]=temp; } } } } void display(){ System.out.println("\n Your Data is .....\n"); for(int i=0;i
16. A college maintains the information about the marks of...
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
17. In the above exercise, use multithreading, to compute 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
18. In the class Statistics defined earlier add method to find 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
19. A Frequency Distribution is a tabular summary of data showing...
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
20. Create subclass of the Frequency Distribution class called...
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
0 comments:
Post a Comment