ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1068. Sum

Compilation error showing bad class hierarchy but wrking correctly in idle
Posted by Paul 6 Nov 2012 17:47
package practice;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Sum {


    public static void main(String[] args) {
        // TODO Auto-generated method stub
        //Scanner sc = new Scanner (System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = 0;
        int sum = 0;
        try {
            x = (int)br.read();
            System.out.println("x" +x);
            if(x >0){
                for(int i =1; i <= x ;i++){
                    sum = sum +i;
                }
                }
                else {
                    for(int i =x; i <=1 ;i++){
                        sum = sum +i;
                    }
                }

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }




        System.out.println(sum);
    }

}