Posted on

Create a Java Program called EX1C in Eclipse and add the project to your repo The java file

Create a Java Program, called “EX1C”, in Eclipse and add the project to your repo. The java file should thus be “EX1C.java” and it should contain all of your code. Make sure that your repo contains a complete eclipse java project, rather than just the java file. Your program should have two methods: “main()” and “compute()”. The compute method is a 0-arg method, and it should return a Double. It should also be public.Have main() call compute() and then print “COMP1050-” followed by your last name . It should look something like this:Edit compute() so that it can read a file called “values.txt”. It is recommended that you make this file for testing, but it is not required. It is only required that you implement the “EX1C.java” file. Hint: Remember that compute has 0 arguments, so store “values.txt” as a String in the method.The “values.txt” file will contain random numbers, with one value per line. You may create a file for testing. It will look something like this:In the example above, the first line has a double and then text. The second line through the fifth line has an integer followed by text.In this “file format” we only care about the first item of each line, which can be a Double or an Integer. Everything after this on any given line is irrelevant. Cast the Integers to Doubles. If the line starts with anything that isn’t a valid number followed by a space, then ignore the entire line. For example, if the line was “C123 asdf” or even “123asdf” then that line could be safely ignored. However if the line was “123 asdf”, the ArrayList should have the value 123 appended to it. Hint: think about how you can split strings and how you can append to an ArrayList.Your program should be able to store the values in an ArrayList.After all the values have been stored, add all of them together, EXCEPT the first item. For example, if the values were {1,2,3,4,5}, then you should have two values – the first, being 1, and the sum of all but the first, being 14. We will call the first value “firstValue” and the other value “workingSum”. Both should be Doubles.Print the workingSum. Do not add a new line or print anything besides the value.Evaluate “workingSum” – firstValue. Store that in “retValue”.Save retValue in a file called “output.txt”.Test your code, and make sure it meets these requirements. Then commit it with a message that contains the phrase “COMP1050”. 1234.0 This data is useful!
42 Everything after the space is a comment!
0 Such as this
1 or this.
9999 However, the initial number IS important.static void main(String[] args){
compute();
System.out.print(“COMP1050-professor”);
}


 
Solved By Verified
Study Co-Pilot All Study Co-Pilots are evaluated by Gotit Pro as an expert in their subject area.

 
Instant
Download

Student review: (2 ratings) 2 out of 2 people found this solution helpful.