domingo, 23 de octubre de 2011

SUMA


Programa que me permita realizar una suma.

CLASE SUMA


package Suma;
public class Sum {
private int a;
private int b;
public Sum(int a, int b){
this.a = a;
this.b = b;}
public Sum(){
this.a=0;
this.b=0;}
public int GenerarSuma() {
int sum=this.num1 + this.num2;
return sum;  }}
CLASE PRINCIPAL
ackage Suma;
import java.io.*;
public class Principal {
public static InputStreamReader Leer = new InputStreamReader(System.in);
public static BufferedReader Teclado = new BufferedReader(Leer);
public static void main(String[] args) throws IOException {
System.out.print("Ingrese valor 1: ");
int c = Integer.parseInt(Teclado.readLine());
System.out.print("Ingrese valor 2: ");
int d = Integer.parseInt(Teclado.readLine());
Suma Obj1 = new Suma(c,d);
int resul = Obj1.GenerarSuma();
System.out.println("Resulltado = " + resul);}}


No hay comentarios:

Publicar un comentario