VUsolutions Transferred to AchiKhasi.com
From December 2011, this blog www.VUsolutions.blogspot.com is transferred to http://achikhasi.com/vu/ . So, you may visit http://achikhasi.com/vu/ for latest study related help.
Back to home VUsolutions
VUsolutions Fans Club [join us for MORE solutions]
VUsolutions on Facebook
Important & Cool Links
Islamic Books in Urdu ! Beauty Tips in Urdu ! Online VU Lectures ! Unique Wallpapers ! Cooking Recipes - Urdu ! Women Kahani Ghar ! Health Tips in Urdu ! Showbiz Hidden Stories ! News Updates Online ! Bachon Ki Duniya ! Virtual University Study ! Prep to PhD Study Help ! Girls Women Block ! AIOU Study Block ! News & Politics Block ! Mix Plate Block - Others
Online Quiz # 01
All Students of Fall Semester 2011 are informed that Online Quiz # 01 for
“Research Methods (STA630)” will be uploaded according to the following schedule:
Opening Date and Time : October 31, 2011 At 12:01 AM
Closing Date and Time : November 01, 2011 At 11:59 PM
CS602 Assignment No. 1 Fall 2011 - solution soon
Sunday, October 30, 2011 Posted In CS and IT Edit ThisCS506 Assignment No. 1 Fall 2011 Solution
Sunday, October 30, 2011 Posted In CS and IT Edit ThisQuestion:
Write a program that computes the average and standard deviation of the text floating point numbers in a file. Use the following formulas for the average and the standard deviation of N values. The formulas compute the sum, the sum of squares, the average, the average square, the variance, and finally, the standard deviation.
sum = x1 + x2 + x3 + ... + xN-1 + xN
sumSQ = x12 + x22 + x32 + ... + xN-12 + xN2
avg = sum/N
avgSQ = sumSQ/N
var = avgSQ - avg2
sd = var(1/2)
The input file will contain any number text floating point numbers, similar to the following:
10.5
12.9
9.67
12.05
8.23
10.08
10.23
7.7
10.4
11.34
Numbers could be several, or none per line, and negative numbers are perfectly OK.
Solution:
Input Text:
10.0
20.0
30.0
40.0
50.0
............
SAVE THIS FILE IN .JAVA
import java.io.*;
import java.util.*;
import javax.swing.*;
public class assignment1{
public static void main( String args[] ){
try{
FileReader fr = null;
BufferedReader br = null;
fr = new FileReader ("input.txt");
br = new BufferedReader (fr);
String line = br.readLine();
double sum =0 ;
while (line != null) {
double num = Double.parseDouble(line);
sum += num;
line = br.readLine();
}
JOptionPane.showMessageDialog(null, "Sum = " + sum);
br.close();
fr.close();
}
catch(NumberFormatException nfEx) {
System.out.println(nfEx);
}
catch(FileNotFoundException fnfEx){
System.out.println(fnfEx);
}
catch(IOException ioEx){
System.out.println(ioEx);
}
}
}
Back to home VUsolutions
Shaadi.com: Just create ur account & find ur partner or EARN money, its reall & EASY
VUsolutions Followers (Join NOW and Get Extra Benefits)
VU related Blogs
Install LATEST toolbar having lot of features - GET solutions on Desktop
toolbar powered by Conduit |