javau3p9

import java.util.*; class superclass { public double x[]=new double[10],fi[]=new double[10],res[]=new double[10],temp=0,temp2=0; public int i,size; public void setx() { Scanner sc=new Scanner(System.in); System.out.println("Enter Size"); size=sc.nextInt(); System.out.println("Enter x"); for(i=0;i<size;i++) { x[i]=sc.nextDouble(); } System.out.println("Enter fi"); for(i=0;i<size;i++) { fi[i]=sc.nextDouble(); } } public void add() { for(i=0;i<size;i++) { res[i]=((x[i])*(fi[i])); } for(i=0;i<size;i++) { temp=temp+res[i]; temp2=temp2+fi[i]; } } public void show() { System.out.println("\n\tx\tfi\tfixi\n"); for(i=0;i<size;i++) { System.out.println("\n\t"+x[i]+"\t"+fi[i]+"\t"+res[i]+"\n"); } System.out.println("========================================="); System.out.println("\n\t\t"+temp2+"\t"+temp+"\n\n"); System.out.println(" A.M = "+(temp/temp2)); } } public class pro3e extends superclass { public int a; public double d[]=new double[10],fd[]=new double[10],d2[]=new double[10],fd2[]=new double[10],resd=0,resd2=0,resfd=0,resfd2=0,mas,mas2; public void setall() {a=size/2; for(i=0;i<size;i++) { d[i]=((x[i])-(x[a])); d2[i]=d[i]*d[i]; fd[i]=((fi[i])*(d[i])); fd2[i]=((fd[i])*(d[i])); resd=resd+d[i]; resd2=resd2+d2[i]; resfd=resfd+fd[i]; resfd2=resfd2+fd2[i]; } } public void showw() { System.out.print("\n\tx\tfi\tdi=xi-A(A="+x[a]+")\t\tfd\td2\tfd2\n"); for(i=0;i<size;i++) { System.out.print("\n\t"+x[i]+"\t"+fi[i]+"\t"+d[i]+" \t\t"+fd[i]+"\t"+d2[i]+"\t"+fd2[i]+"\n"); } System.out.println("======================================================================================="); System.out.print("\n\t\t"+temp2+"\t"+resd+" \t\t"+resfd+"\t"+resd2+"\t"+resfd2+"\n"); mas=((resfd2/temp2))-(((resfd)*(resfd))/((temp2)*(temp2))); mas2=Math.sqrt(mas); System.out.println("\n\n S.D = "+mas2); } public static void main(String ar[]) { pro3e obj=new pro3e(); obj.setx(); obj.add(); obj.show(); obj.setall(); obj.showw(); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.