class VersionAddition
{
void firstVersion()
{
System.out.println("Enter the two no.s->");
int a=Integer.parseInt(System.console().readLine("enter the valye fo first no. ="));
int b=Integer.parseInt(System.console().readLine("enter the valye fo second no.="));
int sum=a+b;
System.out.println("sum of two integer ="+sum);
}
void secondVersion()
{
System.out.println(" ");
System.out.println("Enter the three no.s->");
int c=Integer.parseInt(System.console().readLine("enter the valye fo first no. ="));
int d=Integer.parseInt(System.console().readLine("enter the valye fo second no.="));
int e=Integer.parseInt(System.console().readLine("enter the valye fo third no.="));
int sum=c+d+e;
System.out.println("sum of three integer ="+sum);
}
void thirdVersion()
{
System.out.println(" ");
System.out.println("Enter the four no.s->");
int f=Integer.parseInt(System.console().readLine("enter the valye fo first no. ="));
int g=Integer.parseInt(System.console().readLine("enter the valye fo second no.="));
int h=Integer.parseInt(System.console().readLine("enter the valye fo third no.="));
int i=Integer.parseInt(System.console().readLine("enter the valye fo forth no.="));
int sum=f+g+h+i;
System.out.println("sum of four integer ="+sum);
}
public static void main(String args[])
{
VersionAddition v=new VersionAddition();
v.firstVersion();
v.secondVersion();
v.thirdVersion();
}
}
No comments:
Post a Comment