Friday, October 31, 2014

A Basic Calc using Java

This is the code snippet for a basic add program by getting the user input.
import java.util.Scanner;
public class BacisCalc {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double fnum,snum,answer;
System.out.println("Enter the First number: ");
fnum = sc.nextDouble();
System.out.println("Enter the Second number: ");
snum = sc.nextDouble();
answer = fnum + snum;
System.out.println(answer);
}
}
view raw BasicCalc.java hosted with ❤ by GitHub
Enter the First number:
53.5
Enter the Second number:
65.9
119.4
view raw output.txt hosted with ❤ by GitHub

No comments:

Post a Comment