Afişează mesaje
Pagini: [1]
1  infoarena - concursuri, probleme, evaluator, articole / Arhiva de probleme / Răspuns: 000 A+B : Iunie 26, 2018, 17:50:37
Cand incarc problema pe site primesc urmatoarea eroare :

Eroare de compilare: Main.java:4: error: class Sum is public, should be declared in a file named Sum.java public class Sum ^ 1 error

Insa problema pe calculator merge fara probleme. Idei ?

import java.io.*;
import java.util.*;

public class Sum
{
    public static void main (String[] args)
    {
       Scanner input = null;
       PrintStream output = null;


       int firstNumber, secondNumber, sum;

       try
       {

          input = new Scanner(new File("adunare.in"));
          output = new PrintStream("adunare.out");

          // read the numbers from the file
          firstNumber = input.nextInt();
          secondNumber = input.nextInt();
          // compute the sum of the 2 numbers
          sum = firstNumber + secondNumber;

          // print the sum in to the output file
          output.print(sum);
          output.flush();

          // close the 2 files
          input.close();
          output.close();

       }
       catch (IOException exception)
       {
          System.err.println(exception);
       }
    }
}
2  Comunitate - feedback, proiecte si distractie / Feedback infoarena / A+B problema in JAVA eroare de compilare : Iunie 26, 2018, 08:40:56
Cand incarc problema pe site primesc urmatoarea eroare :

Eroare de compilare: Main.java:4: error: class Sum is public, should be declared in a file named Sum.java public class Sum ^ 1 error

Insa problema pe calculator merge fara probleme. Idei ?

import java.io.*;
import java.util.*;

public class Sum
{
    public static void main (String[] args)
    {
       Scanner input = null;
       PrintStream output = null;


       int firstNumber, secondNumber, sum;

       try
       {

          input = new Scanner(new File("adunare.in"));
          output = new PrintStream("adunare.out");

          // read the numbers from the file
          firstNumber = input.nextInt();
          secondNumber = input.nextInt();
          // compute the sum of the 2 numbers
          sum = firstNumber + secondNumber;

          // print the sum in to the output file
          output.print(sum);
          output.flush();

          // close the 2 files
          input.close();
          output.close();

       }
       catch (IOException exception)
       {
          System.err.println(exception);
       }
    }
}
Pagini: [1]
Powered by SMF 1.1.19 | SMF © 2006-2013, Simple Machines