Q:

Linear Search using Java

0

This Program is used to calculate Linear Search concept in Java

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

// linear search program 

import java.io.*; 
class ssvlin 
{ 
public static void main(String args[]) throws IOException 
{ 

System.out.println("From equations ax1 + bx1= m ; cx1+dx1 = n"); 
DataInputStream dis = new DataInputStream(System.in); 
System.out.print("Enter your 'a' number :"); 
int a = Integer.parseInt(dis.readLine()); 
System.out.print("Enter your 'b' number :"); 
int b = Integer.parseInt(dis.readLine()); 
System.out.print("Enter your 'c' number :"); 
int c = Integer.parseInt(dis.readLine()); 
System.out.print("Enter your 'd' number :"); 
int d = Integer.parseInt(dis.readLine()); 
System.out.print("Enter your 'm' number :"); 
int m = Integer.parseInt(dis.readLine()); 
System.out.print("Enter your 'n' number :"); 
int n = Integer.parseInt(dis.readLine()); 

int dina = (a * d) - (c * b); 
int numr1 = (m * d) - (b * n); 
int numr2 = (n * a) - (m * c); 
System.out.println("your number :" + dina); 
System.out.println("your number :" + numr1); 
System.out.println("your number :" + numr2); 

if (dina==0) 
{ 
System.out.println("The value (ad-cb)becomes Zero"); 
} 
else 
{ 
double x1 = numr1 / dina; 
System.out.println("Result x1 :" + x1); 
double x2 = numr2 / dina; 
System.out.println("Result x2 :" + x2); 
} 
} 
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now