Thursday, November 25, 2010

for DIT 11 Irregular

this is a sample program to compute two numbers and get the sum.

i hope you learn and enjoy....

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

public class Computation
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
int num1,num2,sum=0;
System.out.print("Enter first number:");
num1=input.nextInt();

System.out.print("Enter second number:");
num2=input.nextInt();

sum=num1 + num2;

System.out.println("The sum is:" + sum);
}
}

No comments:

Post a Comment