-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcomplex.java
More file actions
69 lines (69 loc) · 1.58 KB
/
complex.java
File metadata and controls
69 lines (69 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import java.util.Scanner;
class relactiona
{
int num,den;
Scanner reading = new Scanner(System.in);
public relactiona()
{
num = 0 ;
den = 1 ;
}
public relactiona( int x , int y)
{
if ( y == 0 )
{
System.out.println("Enter Correct data.");
System.exit(0);
}
num = x ;
den = y ;
}
void input()
{
System.out.println("Enter value of num. :: ");
num = reading.nextInt();
System.out.println("Enter value of den. :: ");
den = reading.nextInt();
}
void output()
{
System.out.println( num + "/" + den );
}
void munt( relactiona a,relactiona b )
{
num = a.num*b.num;
den = a.den*b.den;
}
}
public class complex extends relactiona
{
int real,img;
Scanner reading = new Scanner(System.in);
public complex()
{
real = 0 ; img = 0;
}
public complex( int x , int y )
{
real = x ; img = y;
}
void output()
{
System.out.println( real + "+" + "i" + img );
super.output();
}
void input()
{
super.input();
System.out.println("Enter value of Real :: ");
real = reading.nextInt();
System.out.println("Enter value of Img. :: ");
img = reading.nextInt();
}
public static void main( String [] args )
{
complex obj2 = new complex();
obj2.input();
obj2.output();
}
}