Semoga bermanfaat!
Input Matriks |
Menu program |
Untuk fungsi tambah, kurang, dan kali silahkan buat sendiri.using System;namespace CA_Matriks_Pake_Class{class Program{static void Main(string[] args){Matriks matriks1 = new Matriks();Console.WriteLine("Matriks A");matriks1.bikinMatriks();Console.WriteLine();Matriks matriks2 = new Matriks();Console.WriteLine("Matriks B");matriks2.bikinMatriks();Console.WriteLine();Console.Clear();int kondisi = 1;while (kondisi==1){Console.Clear();Console.WriteLine("1. Input Matriks A dan B");Console.WriteLine("2. Penjumlahan Matriks");Console.WriteLine("3. Pengurangan Matriks");Console.WriteLine("4. Perkalian Matriks");Console.WriteLine("5. Exit");Console.Write("Your Choice : ");int pil = Convert.ToInt32(Console.ReadLine());switch (pil){default:continue;case 1:Console.Clear();Console.WriteLine("Input lagi");Console.ReadLine();break;case 2:Console.Clear();Console.WriteLine("Jumlah");Console.ReadLine();break;case 3:Console.Clear();Console.WriteLine("Pengurangan");Console.ReadLine();break;case 4:Console.Clear();Console.WriteLine("Perkalian");Console.ReadLine();break;case 5:Console.Clear();kondisi = 0;break;}}}}public class Matriks{public int element1;public int element2;public int element3;public int element4;public Matriks(){this.element1 = 0;this.element2 = 0;this.element3 = 0;this.element4 = 0;}public Matriks(int a, int b, int c, int d){this.element1 = a;this.element2 = b;this.element3 = c;this.element4 = d;}public void bikinMatriks(){int[] nilai = new int[4];for (int i=0; i <= 3; i++){Console.Write("Masukkan nilai matriks ke-" + (i + 1) + " : ");nilai[i] = Convert.ToInt32(Console.ReadLine());Console.WriteLine();}this.element1 = nilai[0];this.element2 = nilai[1];this.element3 = nilai[2];this.element4 = nilai[3];
}public void cetakMatriks(){Console.WriteLine(Convert.ToString(this.element1) + " " + Convert.ToString(this.element2));Console.WriteLine(Convert.ToString(this.element3) + " " + Convert.ToString(this.element4));}}}
Untuk filenya bisa didownload disini.
Jangan lupa komment nya ya! Peace! ^^