Question: Develop body of the method public static void readWrite(String srcfileName , String dstfileName ) The srcfileName contains series of double numbers. The method should copy
Develop body of the method
public static void readWrite(StringsrcfileName, StringdstfileName)
ThesrcfileNamecontains series of double numbers. The method should copy contents of thesrcfileNameintodstfileName,and then it should calculate the average of the numbers, and add it to the end of thedstfileName.
for example if the content of thesrcfileNameis
2.5
3.1
4.2
5.6
then the content of thedstfileNameshould be
2.5
3.1
4.2
5.6
Average = 3.85
Notes:
1.You need to import appropriate packages, otherwise the program will not compile.
2.Do not check if the files exists.
it should look something like this:
// Import packages public class Test10{ public static void main(String[] args) { // Test cases readWrite("test1.txt", "out1.txt"); readWrite("test2.txt", "out2.txt"); } /** copies the content of the srcFileName into dstFileName, and add the average of the number to the end of the dstFileName @param srcFileName : souce file name contains double numbers @param dstFileName : destination file name */ public static void readWrite(String srcFileName, String dstFileName) { // Your code goes here } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
