Comrades, I need help with the following:
there is a text file with a string in the form

числоА1;ЧислоБ1;ЧислоВ1;ЧислоГ1 

or separated by a space / comma (but better not a comma, because fractional numbers)

Then, either through the interface or through the console, I have to enter in order

 ЧислоА2, ЧислоБ2, ЧислоВ2, ЧислоГ2 

The program must, for example, from ЧислоА2 subtract ЧислоА1 , from ЧислоБ2 subtract ЧислоБ1 and so on.

write new results like

 ЧислоА3;ЧислоБ3;... 

Accordingly, with the following. addressing the program, he must give me to calculate the last digits of ЧислоА3 and so on.

How best to implement this?

Closed due to the fact that off-topic participants aleksandr barakin , Vartlok , Vladimir Martyanov , Saidolim , D-side 12 Apr '16 at 16:17 .

  • Most likely, this question does not correspond to the subject of Stack Overflow in Russian, according to the rules described in the certificate .
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • four
    You write that need help. Do I understand correctly that you have already done most of the work? Show what you already have and tell us what is missing. - VladD
  • 6
    I vote for the closure of this question, since the answer to it can hardly be useful to anyone other than the author of the question. - aleksandr barakin

1 answer 1

Since you are asking for help, I will show you the basic steps:

  1. Read file
  2. Read numbers from console / interface
  3. Derive the difference of these numbers

Paragraph 1.
The enSO shows how to write numbers to an array from a file.

 String[] arr = reader.readLine().split(";"); int[] intarr = new int[arr.length]; for(int i = 0; i < arr.length; i++) intarr[i] = Integer.parseInt(arr[i]); 

Point 2.
Now we need to enter numbers into the array from the console, the Scanner will be useful:

  Scanner sc = new Scanner(System.in); int[] arr = new int[4]; System.out.println("Введите 4 числа:"); for (int i = 0; i < 4; i++) { arr[i] = sc.nextInt(); } 

Point 3.
Conclusion:

  for (int i = 0; i < 4; i++) { System.out.println(intarr[i] - arr[i]); } 
  • Thanks, it turned out. - batman