InstagramTwitterSnapChat


 
وصف

العودة   منتديات سكاو > الكليات الجامعية > منتدى كلية الحاسبات وتقنية المعلومات > منتدى قسم علوم الحاسبات
   
   


مساعدة بالكود ...

منتدى قسم علوم الحاسبات

إضافة رد
 
أدوات الموضوع إبحث في الموضوع انواع عرض الموضوع
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
  #1  
قديم 15-12-2011, 03:56 PM

SULTAN AL-MANSOUR SULTAN AL-MANSOUR غير متواجد حالياً

جامعي

 
تاريخ التسجيل: Dec 2011
التخصص: Computer Scince
نوع الدراسة: إنتظام
المستوى: الخامس
الجنس: ذكر
المشاركات: 1
افتراضي مساعدة بالكود ...




السؤال كآلتآلي ..ْ~




3. Matrix Class – Code a class to manage matrices of integers and includes method to add them and another one to subtract them. Create in the driver class two objects of it and let the user to choose the operation he/she wants to perform on them.



و ال////////////////Main ///////////////////


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package matriix;
import java.util.*;

/
*
* @author TOSHIBA
*/
public class Main {

/
* @param args the command line arguments
*/
public static void main(String[] args) {
Matrix f1 = new Matrix();
Matrix f2 = new Matrix();
int [][] m1=new int [3][3];
int [][] m2=new int [3][3];
Scanner s=new Scanner(System.in);
System.out.println("Enter the number of the first matrix:");
for (int i=0;i<m1.length;i++){
for (int j=0;j<m1.length;j++){
m1[i][j]=s.nextInt();
System.out.println(m1+" ");
}
}
System.out.println("Enter the number of the second matrix:");
for (int i=0;i<m2.length;i++){
for (int j=0;j<m2.length;j++){
m2[i][j]=s.nextInt();
System.out.println(m2+" ");
}
}
System.out.println("Please select the operation:");
System.out.println("1- Add\n2- Subtract ");
int choice=s.nextInt();
switch (choice){
case 1:
f1.add(m1, m2);
break;
case 2:
f2.sub(m1, m2);
break;
}

}

}


////////////////////////////// The Class//////////////////


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package matriix;

import java.util.Scanner;

/
*
* @author TOSHIBA
*/
public class Matrix {

int [][]sum=new int [3][3];
int [][]sub=new int [3][3];
int [][] m1=new int [3][3];
int [][] m2=new int [3][3];
Scanner s= new Scanner(System.in);
public void add(int [][]m1,int [][]m2){
System.out.println("The sum of two matrices is:");
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
sum[i][j] = m1[i][j] + m2[i][j];
System.out.print(sum[i][j] + " ");
}}}
public void sub(int [][]m1,int [][]m2){
System.out.println("The subtract of two matrices is:");
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
sub[i][j] = m1[i][j] - m2[i][j];
System.out.print(sub[i][j] + " ");



}
}
}
}

[COLOR="rgb(139, 0, 0)"]الكود أشتغل بس في الرن يطلع رموز غريبة مع الأرقام :( نقرتين لعرض الصورة في صفحة مستقلة[/COLOR]
رد مع اقتباس

 

إضافة رد

أدوات الموضوع إبحث في الموضوع
إبحث في الموضوع:

البحث المتقدم
انواع عرض الموضوع

تعليمات المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code is متاحة
كود [IMG] متاحة
كود HTML معطلة

الانتقال السريع

 


الساعة الآن 03:09 PM


Powered by vBulletin® Version 3.8.9 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Ads Organizer 3.0.3 by Analytics - Distance Education

أن كل ما ينشر في المنتدى لا يمثل رأي الإدارة وانما يمثل رأي أصحابها

جميع الحقوق محفوظة لشبكة سكاو

2003-2023