Menghitung Nilai Menggunakan Struct C# Posted by Unknown on January 13, 2015 Get link Facebook X Pinterest Email Other Apps Dengan keterangan program : - Input berupa : NIM, Nama, Nilai Teori (Tugas, UTS, dan UAS), dan Nilai Praktek (Tugas, UTS, dan UAS). - Manfaatkan struct untuk menyimpan semua input dan outputnya. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MODUL4_1 { class Program { struct pesan { public string nim, nama; } struct nilai { public int tugas, uts, uas; } struct hasil { public float teori, praktek, keseluruhan; } static void Main(string[] args) { pesan tampil; nilai teori, praktek; hasil hasil; Console.Write("NIM = "); tampil.nim = Console.ReadLine(); Console.Write("Nama= "); tampil.nama = Console.ReadLine(); Console.WriteLine("\n"); Console.WriteLine("Nilai Teori :"); Console.Write("\tTugas = "); teori.tugas = Convert.ToInt32(Console.ReadLine()); Console.Write("\tUTS = "); teori.uts = Convert.ToInt32(Console.ReadLine()); Console.Write("\tUAS = "); teori.uas = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(); Console.WriteLine("Nilai Praktek :"); Console.Write("\tTugas = "); praktek.tugas = Convert.ToInt32(Console.ReadLine()); Console.Write("\tUTS = "); praktek.uts = Convert.ToInt32(Console.ReadLine()); Console.Write("\tUAS = "); praktek.uas = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(); Console.WriteLine("Hasil Akhir:"); hasil.teori = (float)0.2 * teori.tugas + (float)0.3 * teori.uts + (float)0.5 * teori.uas; hasil.praktek = (float)0.2 * praktek.tugas + (float)0.3 * praktek.uts + (float)0.5 * praktek.uas; hasil.keseluruhan = 0.4f * hasil.praktek + 0.6f * hasil.teori; Console.WriteLine("\t Teori \t\t=" + hasil.teori); Console.WriteLine("\t Praktek \t\t=" + hasil.praktek); Console.WriteLine("\t Nilai Hasil keseluruhan=" + hasil.keseluruhan); Console.ReadKey(); } } } Comments
Comments
Post a Comment