import java.util.Scanner;
public class MatrixInverse { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = 2; double[][] matrix = new double[n][n]; double[][] inverse = new double[n][n]; System.out.println("Enter elements of 2x2 matrix:"); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { matrix[i][j] = scanner.nextDouble(); } } double det = determinant(matrix); if (det == 0) { System.out.println("Matrix is singular, can't find its inverse."); } else { inverse(matrix, inverse, det); System.out.println("Inverse of the matrix is:"); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { System.out.print(inverse[i][j] + " "); } System.out.println(); } } } public static double determinant(double[][] matrix) { return (matrix[0][0] * matrix[1][1]) - (matrix[0][1] * matrix[1][0]); } public static void inverse(double[][] matrix, double[][] inverse, double det) { inverse[0][0] = matrix[1][1] / det; inverse[0][1] = -matrix[0][1] / det; inverse[1][0] = -matrix[1][0] / det; inverse[1][1] = matrix[0][0] / det; } }Happy Learning
Monday, May 27, 2024
Wednesday, December 6, 2023
A.Y. 2024-25 Data Mining (Computer Science and Engineering)
Student's Lecture Notes for University Examinations for quick reference.
Regulation: R18
Subject: Data Mining Syllabus
Descriptive Question Bank
Objective Question Bank
Unit-1 :
Introduction to Data Mining Notes Click Here
Data Preprocessing Hand Written Note Click Here
Data Mining Unit-1 Important Question and Answers Click Here
Unit-1 ppt Click Here
Unit-2:
Notes Click Here
Unit-1 ppt Part-1 Click Here
Unit-2 ppt Part-2 Click Here
FP-Growth ppt Click Here
Question and Answers Click Here
Unit-3
Notes: Click Here
Classification and Prediction ppt Click Here
Decision tree Classification ppt Click Here
Lazy Learner and Rule Based Classification ppt Click Here
Question and Answers Click Here
Unit-4
Notes: Click Here
Clustering and its Applications- Hierarchical Clustering ppt Click Here
Density Based Clustering ppt Click Here
Partitioning Clustering ppt Click Here
Question and Answers Click Here
Unit-5
unit-5 ppts: Click Here
Time Series Mining and Sequential Pattern Mining ppt Click Here
Spatial Data Mining ppt Click Here
Text Mining Click Here
Multimedia Data Mining Click Here
Question and Answers Click Here
x
Tuesday, September 12, 2023
Python Programming
JNTUH Python Programming(Common to EEE, Mechanical, Civil) Syllabus: PDF
Question bank: Download
Unit-1 Material Find Here
Material : Download HERE
Handwritten Notes: Click Here
PPT: Find Here
Unit-2 Material Find Here
Material : Download HERE
PPT: Find Here
Unit-3 Material Find Here
Material : Download HERE
PPT: Find Here
Unit-4 Material Find Here
Material : Download HERE
PPT: Find Here
Unit-5 Material Find Here
Material : Download HERE
PPT: Find Here
Monday, May 8, 2023
Write a Java program that simulates a traffic light. The program lets the user select one of three lights: red, yellow, or green with radio buttons. On selecting a button, an appropriate message with “Stop” or “Ready” or “Go” should appear above the buttons in selected color. Initially, there is no message shown.
import java.awt.Color;
import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.*; class App extends JFrame implements ItemListener{ JFrame actualWindow; JPanel messageContainer, lightsContainer; JLabel message; ButtonGroup btn_group; JRadioButton rb_red, rb_yellow, rb_green; App() { Font myFont = new Font("Verdana",Font.BOLD, 50); actualWindow = new JFrame("Traffic Lights"); messageContainer = new JPanel(); lightsContainer = new JPanel(); message = new JLabel(""); btn_group = new ButtonGroup(); rb_red = new JRadioButton("Red"); rb_yellow = new JRadioButton("Yellow"); rb_green = new JRadioButton("Green"); actualWindow.setLayout(new GridLayout(2, 1)); message.setFont(myFont); rb_red.setForeground(Color.RED); rb_yellow.setForeground(Color.YELLOW); rb_green.setForeground(Color.GREEN); btn_group.add(rb_red); btn_group.add(rb_yellow); btn_group.add(rb_green); rb_red.addItemListener(this); rb_yellow.addItemListener(this); rb_green.addItemListener(this); messageContainer.add(message); lightsContainer.add(rb_red); lightsContainer.add(rb_yellow); lightsContainer.add(rb_green); actualWindow.add(messageContainer); actualWindow.add(lightsContainer); actualWindow.setSize(300, 200); actualWindow.setVisible(true); } @Override public void itemStateChanged(ItemEvent ie) { JRadioButton selected = (JRadioButton) ie.getSource(); String textOnButton = selected.getText(); if(textOnButton.equals("Red")) { message.setForeground(Color.RED); message.setText("STOP"); } else if(textOnButton.equals("Yellow")) { message.setForeground(Color.YELLOW); message.setText("READY"); } else { message.setForeground(Color.GREEN); message.setText("GO"); } } } public class TrafficLight { public static void main(String[] args) { new App(); } }
Write a Java program that handles all mouse events and shows the event name at the center of the window when a mouse event is fired .
Program
Code:
import
javax.swing.event.*;
import
java.awt.event.*;
import
java.awt.*;
import javax.swing.JApplet;
public class
mouseevnts extends JApplet implements MouseListener
{
private int x,y;
private String
event;
public void
init()
{
setLayout(new
FlowLayout());
x=-1;
addMouseListener(this);
}
public void
paint(Graphics g)
{
super.paint(g);
g.drawRect(0,0,getWidth(),getHeight());
if(x!=1)
{
g.drawString("Mouseevent
is"+event+"("+x+","+y+")", 10,50);
}
}
public void
mousePressed(MouseEvent e)
{
x=e.getX();
y=e.getY();
event="pressed";
repaint();
}
public void
mouseClicked(MouseEvent e)
{
x=e.getX();
y=e.getY();
event="clicked";
repaint();
}
public void
mouseReleased(MouseEvent e)
{
x=e.getX();
y=e.getY();
event="Reeleased";
repaint();
}
public void
mouseExited(MouseEvent e)
{
x=e.getX();
y=e.getY();
event="Exited";
repaint();
}
public void mouseEntered(MouseEvent
e)
{
x=e.getX();
y=e.getY();
event="Entered";
repaint();
}
}
Tuesday, April 18, 2023
3. a) Develop an applet in Java that displays a simple message. b) Develop an applet in Java that receives an integer in one text field, and computes its factorial Value and returns it in another text field, when the button named “Compute” is clicked.
a) Develop an applet in Java that displays a simple message.
Program:
import java.awt.*;
import java.applet.Applet;
/* <applet
code="SimpleApplet" width=300 height=50> </applet> */
public class SimpleApplet extends Applet
{
public void paint(Graphics g)
{
g.drawString ("A Simple Applet",100,
100);
}
}
Execution:
C:\Users\vits\Desktop\java> javac
SimpleApplet.java
C:\Users\vits\Desktop\java>appletviewer
SimpleApplet.java
Output:
b) Develop
an applet in Java that receives an integer in one text field, and computes its
factorial Value and returns it in another text field, when the button named
“Compute” is clicked.
Program:
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
/* <applet code="Fact"
width=300 height=50> </applet> */
public class Fact extends Applet
implements ActionListener
{
Label l1,l2; TextField t1,t2; Button b1;
public void init(){
l1=new Label("enter the
value"); add(l1);
t1=new TextField(10); add(t1);
b1=new Button("Factorial");
add(b1); b1.addActionListener(this);
l2=new Label("Factorial of given no
is"); add(l2);
t2=new TextField(10); add(t2);
}
public void actionPerformed(ActionEvent
e)
{
if(e.getSource()==b1)
{
int
fact=fact(Integer.parseInt(t1.getText())); t2.setText(String.valueOf(fact));
}
}
int fact(int f)
{
int s=0;
if(f==0)
return 1;
else
return f*fact(f-1);
}
}
Execution:
C:\Users\vits\Desktop\java>javac Fact.java
C:\Users\vits\Desktop\java>appletviewer
Fact.java
Output:
A simple Java program to find the inverse of a given matrix
import java.util.Scanner; public class MatrixInverse { public static void main (String[] args) { Scanner scanner =...
-
Student's Lecture Notes for University Examinations for quick reference. Regulation: R18 Subject: Data Mining Syllabus Descriptive Q...
-
FLAT Syllabus( R22-CSE- JNTUH ): Click Here Unit-1 : Hand Written Notes Click Here old Notes Click Here Unit-2 : Hand Written Notes ...