Di post ini saya berbagi tentang pemrogaman ASP.NET dimana satu project bisa menjalankan beberapa program. Buka Visual Studio, klik File-New Project
Beri nama VolumeBendaRuang dan Solution nama PraktekCSharp3
Masukkan script sebagai berikut :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VolumeBendaRuang
{
class Program
{
static void Main(string[] args)
{
menu:
Console.Clear();
Console.WriteLine("Hitung Volume + Biodata Inputan");
Console.WriteLine(" 1. Volume Balok\n 2. Volume Kubus\n 3. Volume Kerucut\n 4. Biodata\n");
Console.Write(" -----> Masukkan Pilihan : ");
int a = Convert.ToInt16(Console.ReadLine());
switch (a)
{
case 1:
Console.Clear();
Console.WriteLine("\nProgram Volume Balok");
Console.Write("Masukkan - Panjang : ");
float p = Convert.ToSingle(Console.ReadLine());
Console.Write(" - Lebar : ");
float l = Convert.ToSingle(Console.ReadLine());
Console.Write(" - Tinggi : ");
float t = Convert.ToSingle(Console.ReadLine());
float vb = p * l * t;
Console.Write("Volume Balok : {0} \n", vb);
Console.ReadLine();
goto menu;
case 2:
Console.Clear();
Console.WriteLine("\nProgram Volume Kubus");
Console.Write("Masukkan - Panjang Sisi : ");
float s = Convert.ToSingle(Console.ReadLine());
float vk = s * s * s;
Console.Write("Volume Kubus : {0}\n", vk);
Console.ReadLine();
goto menu;
case 3:
Console.Clear();
Console.WriteLine("\nProgram Volume Kerucut");
float phi = 3.14f;
Console.Write("Masukkan - Jari-jari kerucut : ");
float r = Convert.ToSingle(Console.ReadLine());
Console.Write(" - Tinggi kerucut : ");
float tk = Convert.ToSingle(Console.ReadLine());
float vkr = phi * tk * r;
Console.Write("Volume Kerucut : {0}\n", vkr);
Console.ReadLine();
goto menu;
case 4:
Console.Clear();
string namaLengkap, namapgl, kelas, ttl, agama, alamat, cita2, hobi;
float umur, tinggi, berat;
string input;
Console.WriteLine("\n Masukkan Data Diri Anda =");
Console.Write(" - Nama Lengkap Anda : ");
namaLengkap = Console.ReadLine();
Console.Write(" - Nama Panggilan Anda : ");
namapgl = Console.ReadLine();
Console.Write(" - Kelas Anda : ");
kelas = Console.ReadLine();
Console.Write(" - TTL Anda : ");
ttl = Console.ReadLine();
Console.Write(" - Agama Anda : ");
agama = Console.ReadLine();
Console.Write(" - Alamat Anda : ");
alamat = Console.ReadLine();
Console.Write(" - Cita-cita Anda : ");
cita2 = Console.ReadLine();
Console.Write(" - Hobi Anda : ");
hobi = Console.ReadLine();
Console.Write(" - Umur Anda : ");
input = Console.ReadLine();
float.TryParse(input, out umur);
Console.Write(" - Tinggi Anda : ");
input = Console.ReadLine();
float.TryParse(input, out tinggi);
Console.Write(" - Berat Anda : ");
input = Console.ReadLine();
float.TryParse(input, out berat);
Console.WriteLine("\n\n Data Diri " + namapgl);
Console.WriteLine(" Nama Lengkap : {0}", namaLengkap);
Console.WriteLine(" Nama Panggilan : {0}", namapgl);
Console.WriteLine(" Kelas : {0}", kelas);
Console.WriteLine(" TTL : {0}", ttl);
Console.WriteLine(" Agama : {0}", agama);
Console.WriteLine(" Alamat : {0}", alamat);
Console.WriteLine(" Cita-cita : {0}", cita2);
Console.WriteLine(" Hobi : {0}", hobi);
Console.WriteLine(" Umur : {0}", umur);
Console.WriteLine(" Tinggi : {0}", tinggi);
Console.WriteLine(" Berat : {0}", berat);
Console.ReadLine();
goto menu;
default:
Console.Clear();
Console.Write("Anda salah ketik !!");
Console.ReadLine();
goto menu;
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VolumeBendaRuang
{
class Program
{
static void Main(string[] args)
{
menu:
Console.Clear();
Console.WriteLine("Hitung Volume + Biodata Inputan");
Console.WriteLine(" 1. Volume Balok\n 2. Volume Kubus\n 3. Volume Kerucut\n 4. Biodata\n");
Console.Write(" -----> Masukkan Pilihan : ");
int a = Convert.ToInt16(Console.ReadLine());
switch (a)
{
case 1:
Console.Clear();
Console.WriteLine("\nProgram Volume Balok");
Console.Write("Masukkan - Panjang : ");
float p = Convert.ToSingle(Console.ReadLine());
Console.Write(" - Lebar : ");
float l = Convert.ToSingle(Console.ReadLine());
Console.Write(" - Tinggi : ");
float t = Convert.ToSingle(Console.ReadLine());
float vb = p * l * t;
Console.Write("Volume Balok : {0} \n", vb);
Console.ReadLine();
goto menu;
case 2:
Console.Clear();
Console.WriteLine("\nProgram Volume Kubus");
Console.Write("Masukkan - Panjang Sisi : ");
float s = Convert.ToSingle(Console.ReadLine());
float vk = s * s * s;
Console.Write("Volume Kubus : {0}\n", vk);
Console.ReadLine();
goto menu;
case 3:
Console.Clear();
Console.WriteLine("\nProgram Volume Kerucut");
float phi = 3.14f;
Console.Write("Masukkan - Jari-jari kerucut : ");
float r = Convert.ToSingle(Console.ReadLine());
Console.Write(" - Tinggi kerucut : ");
float tk = Convert.ToSingle(Console.ReadLine());
float vkr = phi * tk * r;
Console.Write("Volume Kerucut : {0}\n", vkr);
Console.ReadLine();
goto menu;
case 4:
Console.Clear();
string namaLengkap, namapgl, kelas, ttl, agama, alamat, cita2, hobi;
float umur, tinggi, berat;
string input;
Console.WriteLine("\n Masukkan Data Diri Anda =");
Console.Write(" - Nama Lengkap Anda : ");
namaLengkap = Console.ReadLine();
Console.Write(" - Nama Panggilan Anda : ");
namapgl = Console.ReadLine();
Console.Write(" - Kelas Anda : ");
kelas = Console.ReadLine();
Console.Write(" - TTL Anda : ");
ttl = Console.ReadLine();
Console.Write(" - Agama Anda : ");
agama = Console.ReadLine();
Console.Write(" - Alamat Anda : ");
alamat = Console.ReadLine();
Console.Write(" - Cita-cita Anda : ");
cita2 = Console.ReadLine();
Console.Write(" - Hobi Anda : ");
hobi = Console.ReadLine();
Console.Write(" - Umur Anda : ");
input = Console.ReadLine();
float.TryParse(input, out umur);
Console.Write(" - Tinggi Anda : ");
input = Console.ReadLine();
float.TryParse(input, out tinggi);
Console.Write(" - Berat Anda : ");
input = Console.ReadLine();
float.TryParse(input, out berat);
Console.WriteLine("\n\n Data Diri " + namapgl);
Console.WriteLine(" Nama Lengkap : {0}", namaLengkap);
Console.WriteLine(" Nama Panggilan : {0}", namapgl);
Console.WriteLine(" Kelas : {0}", kelas);
Console.WriteLine(" TTL : {0}", ttl);
Console.WriteLine(" Agama : {0}", agama);
Console.WriteLine(" Alamat : {0}", alamat);
Console.WriteLine(" Cita-cita : {0}", cita2);
Console.WriteLine(" Hobi : {0}", hobi);
Console.WriteLine(" Umur : {0}", umur);
Console.WriteLine(" Tinggi : {0}", tinggi);
Console.WriteLine(" Berat : {0}", berat);
Console.ReadLine();
goto menu;
default:
Console.Clear();
Console.Write("Anda salah ketik !!");
Console.ReadLine();
goto menu;
}
}
}
}
Jalankan !
RUN dengan F5
Tampilan Program Volume Balok
Tampilan Program Volume Kubus
Tampilan Program Volume Kerucut
Tampilan Program Biodata
Jika yang diinputkan salah, maka akan muncul clear screen dengan tulisan
Terima kasih
0 comments:
Post a Comment