1. Engineering
  2. Computer Science
  3. write a program example java that behaves as follows ...

Question: write a program example java that behaves as follows ...

Question details

Write a program Example java that behaves as follows . The program takes two command line arguments, a filename f and an integer size n (you can assume n > 0). It creates an array of n points, where points are represented as objects of this class: static class P double double y P (double x, double y) ithis.x-x this y y) . It initializes each element of the array to contain the point (0.0,0.0) . It opens file f and reads co parameters whose meaning depends on the operation. ds and executes commands from it until the end of file is reached. Each command consi ists of an operation name followed by one or more space separated PRINT i prints a comma-separated pair of doubles representing the coordina tes of the point in array location i, where i is an integer with Osin. -SETi xy updates array location i to contain the point(X,Y), where x and y are doubles and i is an integer with OSi<n. , array location j to contain the point (x y) where array location i currently contains point (a.x) and ij are integers with If you find this description confusing (perhaps thats the point?) it should hel p to know that given any size n 2 3, the expected output for the sample data file PRINT 1 SET 11010 PRINT 1 PRINT 2 SET 22020 COPY 21 PRINT 1 SET 2 2.5 2.5 PRINT 1 PRINT 2 0.0,0.0 1.0,1.0 0.0,0.0 2.0,2.0 2.0,2.0 20,2.0 2.5,2.5 Helpful implenentation hints . The Scanner dlass has methods String next (1 to fetch the next white- space delirmited string from the file, and Boolean hasNext () to check whether there are any more items in the file. To test wtieleter ocod sistentry worne sequence of characters, use a method call 1, equalss2) rather than s1 - 2. (You should be able to make a good guess about why the latter does rfot consistentry work.)

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution