Your SlideShare is downloading. ×
Java Week2(B)   Notepad
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Java Week2(B) Notepad

278

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
278
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. JAVA WEEK2(B) /* Week 2 : b) Write a Java program to multiply two given matrices. */ import javax.swing.*; public class week2(B) { public static void main(String args[]) { String n,l,m=" "; int i,j,k; int a[][]=new int[3][3]; int b[][]=new int[3][3]; int c[][]=new int[3][3]; for(i=0;i<3;i++) { for(j=0;j<3;j++) { n=JOptionPane.showInputDialog(null,"enter elements of 1st matrix"); a[i][j]= Integer.parseInt(n); } } for(i=0;i<3;i++) { for(j=0;j<3;j++) { l=JOptionPane.showInputDialog(null,"enter elements of 2nd matrix"); b[i][j]= Integer.parseInt(l); } } for(i=0;i<3;i++) { for(j=0;j<3;j++) { c[i][j]=0; for(k=0;k<3;k++) c[i][j]=c[i][j]+a[i][k]*b[k][j]; } } for(i=0;i<3;i++) { for(j=0;j<3;j++) { m=m+c[i][j]; } m=m+"n"; JOptionPane.showMessageDialog(null,"resultant matrix is"+m); } } } Page 1

×