diff --git a/.idea/misc.xml b/.idea/misc.xml index a165cb3..d5d79e0 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/repl/Main.java b/src/repl/Main.java index 625a751..473a1c6 100644 --- a/src/repl/Main.java +++ b/src/repl/Main.java @@ -1,7 +1,25 @@ package repl; +import java.util.Scanner; + public class Main { public static void main(String[] args) { - System.out.print("Hello world!"); + Scanner in = new Scanner(System.in); + while (true) { + String s = in.nextLine(); + if (s.equals("/exit")) { + System.out.println("Buy!"); + return; + } else if (s.equals("/help")) { + System.out.println("The program calculates the sum of numbers"); + } else { + String[] ary = s.split(" "); + int result = 0; + for (String num : ary) { + result += Integer.parseInt(num); + } + System.out.println(result); + } + } } } \ No newline at end of file