package MCA;
import java.io.*;
class Mathematics
{
float a,b,c;
int p,q;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public int add_i()
{
try
{
System.out.println("Enter two integers");
p=Integer.parseInt(br.readLine());
q=Integer.parseInt(br.readLine());
}
catch(Exception ex){}
return (p+q);
}
public float add_f()
{
try
{
System.out.println("Enter three floats");
a=Float.parseFloat(br.readLine());
b=Float.parseFloat(br.readLine());
c=Float.parseFloat(br.readLine());
}
catch(Exception ex1){}
return (a+b+c);
}
}
class Maximum
{
int x,y,z,max;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public int check_max()
{
try
{
System.out.println("Enter three integers");
x=Integer.parseInt(br.readLine());
y=Integer.parseInt(br.readLine());
z=Integer.parseInt(br.readLine());
if(x>y&&x>z)
max=x;
else if(y>z)
max=y;
else
max=z;
}
catch(Exception ex3){}
return max;
}
}
class Test
{
public static void main(String args[])
{
Mathematics m=new Mathematics();
System.out.println("Addition of two integers is "+m.add_i());
System.out.println("Addition of three floats is "+m.add_f());
Maximum m1=new Maximum();
System.out.println("Maximum amongst three integers is "+m1.check_max());
}
}
D:\Rushi>javac -d D:\Rushi Test.java
D:\Rushi>java -cp D:\Rushi MCA.Test
Enter two integers
20
30
Addition of two integers is 50
Enter three floats
12.5
52.2
36.4
Addition of three floats is 101.1
Enter three integers
2
5
8
Maximum amongst three integers is 8
import java.io.*;
class Mathematics
{
float a,b,c;
int p,q;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public int add_i()
{
try
{
System.out.println("Enter two integers");
p=Integer.parseInt(br.readLine());
q=Integer.parseInt(br.readLine());
}
catch(Exception ex){}
return (p+q);
}
public float add_f()
{
try
{
System.out.println("Enter three floats");
a=Float.parseFloat(br.readLine());
b=Float.parseFloat(br.readLine());
c=Float.parseFloat(br.readLine());
}
catch(Exception ex1){}
return (a+b+c);
}
}
class Maximum
{
int x,y,z,max;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public int check_max()
{
try
{
System.out.println("Enter three integers");
x=Integer.parseInt(br.readLine());
y=Integer.parseInt(br.readLine());
z=Integer.parseInt(br.readLine());
if(x>y&&x>z)
max=x;
else if(y>z)
max=y;
else
max=z;
}
catch(Exception ex3){}
return max;
}
}
class Test
{
public static void main(String args[])
{
Mathematics m=new Mathematics();
System.out.println("Addition of two integers is "+m.add_i());
System.out.println("Addition of three floats is "+m.add_f());
Maximum m1=new Maximum();
System.out.println("Maximum amongst three integers is "+m1.check_max());
}
}
D:\Rushi>javac -d D:\Rushi Test.java
D:\Rushi>java -cp D:\Rushi MCA.Test
Enter two integers
20
30
Addition of two integers is 50
Enter three floats
12.5
52.2
36.4
Addition of three floats is 101.1
Enter three integers
2
5
8
Maximum amongst three integers is 8
No comments:
Post a Comment