Monday, June 29, 2015

Solve me first

Problem Statement
This is an introductory challenge. The purpose of this challenge is to give you a working I/O template in your preferred language. It includes scanning two integers from STDIN, calling a function, returning a value, and printing it to STDOUT.
The task is to scan two numbers from STDIN, and print the sum A+B on STDOUT. The code has already been provided for most of the popular languages. This is primarily for you to read and inspect how the IO is handled.
Note: The code has been saved in a template, which you can submit if you want. Or, you may try rewriting it and building it up from scratch.
Input Format
(This section specifies the Input Format.)
Given A and B on two different lines.
Output Format
(This section specifies the Output Format.)
An integer that denotes Sum (A+B)

Sample Input
2
3
Sample Output
5


import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {


    static int solveMeFirst(int a, int b) 
     {
        return a+b;
     }

   
 public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a;
        a = in.nextInt();
        int b;
        b = in.nextInt();
        int sum;
        sum = solveMeFirst(a, b);
        System.out.println(sum);
   }
}

0 comments:

Post a Comment