Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3.  
  4. public class Lab4<E> {
  5. Vector <Double> data;
  6. public void readData() throws FileNotFoundException
  7. {
  8. {
  9. Scanner console = new Scanner (System.in);
  10. System.out.println("Enter the data file name: ");
  11. String inFile = console.next();
  12. File fileRef = new File(inFile);
  13. Scanner tokens = new Scanner(fileRef);
  14. data = new Vector<Double>();
  15. while(tokens.hasNext())
  16. {
  17. Double value = tokens.nextDouble();
  18. data.add(value);
  19. }
  20. System.out.print("The values in the file are: "+data.toString()+"n");
  21. System.out.print("The number of values in the file is: "+(data.size())+"n");
  22. tokens.close();
  23. console.close();
  24. }
  25. }
  26. public static void main(String[] args)
  27. throws IOException
  28. {
  29. Lab4 fileTest = new Lab4();
  30. fileTest.readData();
  31. System.out.println(obj);
  32. }
  33.  
  34. class MinMaxObject
  35. {
  36. private double max, min;
  37. private int maxPos, minPos;
  38. public MinMaxObject()
  39. {
  40. this.max =Double.MIN_VALUE;
  41. this.maxPos = 0;
  42. this.min=Double.MAX_VALUE;
  43. this.minPos = 0;
  44.  
  45. }
  46. public MinMaxObject(double ma, int maP, double mi, int miP)
  47. {
  48. this.max = ma;
  49. this.maxPos = maP;
  50. this.min = mi;
  51. this.minPos = miP;
  52. }
  53. public void setMax(double newMax)
  54. {
  55. max = newMax;
  56. }
  57. public double getMax() {
  58. return max;
  59. }
  60. public void setMin(double newMin)
  61. {
  62. min = newMin;
  63. }
  64. public double getMin() {
  65. return min;
  66. }
  67. public void setMaxPos(int newMaxPos)
  68. {
  69. maxPos = newMaxPos;
  70. }
  71. public int getMaxPos() {
  72. return maxPos;
  73. }
  74. public void setMinPos(int newMinPos)
  75. {
  76. minPos = newMinPos;
  77. }
  78. public int getMinPos() {
  79. return minPos;
  80. }
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement