Who can translate this code from Pascal to Java, please help.

uses crt; var min,max,n,q,a:integer; begin write ('Vvedite kolichestvo chisel v posledovatelnosti: '); readln(n); write ('Vvedite posledovatelnost: '); read(max); min:=max; for q:=2 to n do begin read(a); if a>max then max:=a; if a<min then min:=a; end; writeln; write ('Raznica: ',max-min); end. 

Closed due to the fact that the essence of the issue is incomprehensible by the participants of Kromster , Denis , Alexey Shimansky , fori1ton , Harry 29 Sep '16 at 7:40 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • and what did not work with the translation? - Grundy
  • eight
    When the Google translator is finished: D - Qwertiy
  • 3
    I vote for the closure of this issue as not relevant topic, because here they do not translate programs into another language without the author's attempts. - Denis
  • With such questions, it is better to write to freelancing - Vladlen Vozhzhayev
  • @ Alexey Shimansky or just to help in spite of closed questions)) - Senior Pomidor

1 answer 1

  public static void main(String[] args) { int max, min; System.out.println("Введите количество чисел в последовательности "); Scanner sc = new Scanner(System.in); int count = sc.nextInt(); System.out.println("Введите последовательность"); int inputValue = sc.nextInt(); max = inputValue; min = inputValue; for (int i = 0; i < count - 1; i++) { inputValue = sc.nextInt(); if(inputValue > max ) max = inputValue; if(inputValue < min ) min = inputValue; } System.out.println(String.format("Raznica = %s", max - min)); } 

output:

 Введите количество чисел в последовательности 6 Введите последовательность 5 10 0 9 6 8 Raznica = 10