using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AngkaHuruf
{
class Program
{
static void Main(string[] args)
{
Console.Write(" Nama Kampus ???");
Console.WriteLine("\n");
String N;
double n;
Console.Write("Nama Mahasiswa = ");
N = Console.ReadLine();
Console.Write("Masukkan Nilai = ");
n = double.Parse(Console.ReadLine());
if (n <= 0)
{
Console.Write("Maaf, Anda Tak Dapat Huruf / Nilai.");
}
else if (n <= 40)
{
Console.Write("Nilai Anda = E");
}
else if (n <= 55)
{
Console.Write("Nilai Anda = D");
}
else if (n <= 60)
{
Console.Write("Nilai Anda = C");
}
else if (n <= 65)
{
Console.Write("Nilai Anda = BC");
}
else if (n <= 70)
{
Console.Write("Nilai Anda = B");
}
else if (n <= 80)
{
Console.Write("Nilai Anda = AB");
}
else if (n <= 100)
{
Console.Write("Nilai Anda = A");
}
else
{
Console.Write("Nilai harus antara 1 - 100");
}
Console.ReadLine();
}
}
}
2. Array
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Array
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
int r, x;
string status;
double[] p = new double[5];
double[] q = new double[5];
double[] mean = new double[5];
string[] name = new string[50];
Console.Write("MASUKAN JUMLAH DATA MAHASISWA ? : ");
r = Convert.ToInt32(Console.ReadLine());
for (x = 0; x < r; x++)
{
Console.WriteLine("\nData ke- {0} ", x + 1);
Console.Write("Name : ");
name[x] = Console.ReadLine();
Console.Write("Mid Exam : ");
p[x] = Convert.ToDouble(Console.ReadLine());
Console.Write("Final Exam : ");
q[x] = Convert.ToDouble(Console.ReadLine());
}
for (x = 0; x < r; x++)
{
mean[x] = (p[x] + q[x]) / 2;
}
Console.WriteLine("\n\n");
Console.WriteLine("No\tName\t\tMid Exam\tFinal Exam\tAverage\t\tStatus");
Console.WriteLine("------------------------------------------------------------------------------");
for (x = 0; x < r; x++)
{
if (mean[x] >= 60)
{
Console.WriteLine("{0}\t{1}\t\t{2}\t\t{3}\t\t{4}\t\tOke", x + 1, name[x], p[x], q[x], mean[x]);
}
else
{
Console.WriteLine("{0}\t{1}\t{2}\t\t{3}\t\t{4}\t\tNo Oke", x + 1, name[x], p[x], q[x], mean[x]);
}
}
Console.ReadLine();
}
}
}
3. Array Penjumlahan Matrik
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Array_Penjumlahan_Matriks
{
class Program
{
static void Main(string[] args)
{
int x, y;
Console.WriteLine("Masukan Ukuran Matrik : ");
x = int.Parse(Console.ReadLine());
y = x;
Console.WriteLine();
int[,] a = new int[x, y];
int[,] b = new int[x, y];
int[,] c = new int[x, y];
for (int i = 0; i < x; i++)
{
for (int j = 0; j < y; j++)
{
Console.WriteLine("Inputkan Data A [{0},{1}] : ", i, j);
a[i, j] = int.Parse(Console.ReadLine());
}
}
for (int i = 0; i < x; i++)
{
for (int j = 0; j < y; j++)
{
Console.WriteLine("Inputkan Data B [{0},{1}] : ", i, j);
b[i, j] = int.Parse(Console.ReadLine());
}
}
Console.WriteLine();
Console.WriteLine("Hasil Penambahan : ");
for (int i = 0; i < x; i++)
{
for (int j = 0; j < y; j++)
{
c[i, j] = a[i, j] + b[i, j];
Console.WriteLine("{0}", c[i, j]);
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}
4. Biaya Pengiriman
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Biaya_pengirimn
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(" TRANSPORTAS BRANG DAN JASA");
Console.WriteLine("\n");
Console.WriteLine("+-------------------------+");
Console.WriteLine("| Kota Tujuan di Sumatra : |");
Console.WriteLine("| 1. Palembang |");
Console.WriteLine("| 2. Lampung |");
Console.WriteLine("| 3. Belitang |");
Console.WriteLine("| 4. Rasuan |");
Console.WriteLine("| 5. Martapura |");
Console.WriteLine("| 6. Bengkulu |");
Console.WriteLine("| 7. Baturaja |");
Console.WriteLine("| 8. Tanjung Tiga |");
Console.WriteLine("| 9. Kota Baru |");
Console.WriteLine("| 10. Kota Lain |");
Console.WriteLine("+-------------------------+");
String k;
double b;
Console.Write("Nomor Kota Tujuan = ");
k = Console.ReadLine();
Console.Write("Berat Paket (kg) = ");
b = double.Parse(Console.ReadLine());
switch (k)
{
case "1":
Console.WriteLine("Total Biaya = Rp " + (55000 * b) + ",-");
break;
case "2":
Console.WriteLine("Total Biaya = Rp " + (40000 * b) + ",-");
break;
case "3":
Console.WriteLine("Total Biaya = Rp " + (60000 * b) + ",-");
break;
case "4":
Console.WriteLine("Total Biaya = Rp " + (50000 * b) + ",-");
break;
case "5":
Console.WriteLine("Total Biaya = Rp " + (60000 * b) + ",-");
break;
case "6":
Console.WriteLine("Total Biaya = Rp " + (75000 * b) + ",-");
break;
case "7":
Console.WriteLine("Total Biaya = Rp " + (40000 * b) + ",-");
break;
case "8":
Console.WriteLine("Total Biaya = Rp " + (50000 * b) + ",-");
break;
case "9":
Console.WriteLine("Total Biaya = Rp " + (60000 * b) + ",-");
break;
case "10":
Console.WriteLine("Total Biaya = Rp " + (75000 * b) + ",-");
break;
}
Console.WriteLine("==========================================");
Console.Write("Terima Kasih Telah Mempercayakan Jasa Kami");
Console.ReadLine();
}
}
}
5. Bilangan Prima
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BilanganPrima
{
class Program
{
static void Main(string[] args)
{
int i, j, counter;
for (i = 2; i <= 100; i++)
{
counter = 0;
for (j = 2; j <= Math.Sqrt(i); j++)
{
if (i % j == 0)
{
counter++;
}
}
if (counter == 0)
{
Console.WriteLine("{0} adalah bilangan prima", i);
}
}
Console.ReadLine();
}
}
}
6. Conter Pulsa
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConterPulsa
{
class Program
{
public static void Main(string[] args)
{
string jenisPulsa;
int deposit;
int depositTambah;
int pulsaDibeli;
int pulsaJual;
int hargaPulsa = 0;
int laba = 0;
string noHp;
string tanyaUlang = "";
//user interface
Console.WriteLine(" Program Cellular Pulsa All Oprator");
Console.WriteLine(" ----------------------------------");
Console.WriteLine();
//input
Console.Write("Deposit Awal : Rp. ");
deposit = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
Console.WriteLine(" Transaksi PHAI_ZO CELL");
Console.WriteLine(" ---------------------");
do
{
Console.WriteLine();
Console.Write("Jenis pulsa yang dibeli : ");
jenisPulsa = Console.ReadLine();
Console.Write("Masukkan nomer HP : ");
noHp = Console.ReadLine();
Console.Write("Besar pulsa yang dibeli : Rp. ");
pulsaDibeli = Convert.ToInt32(Console.ReadLine());
//Seleksi harga pulsa
if (pulsaDibeli <= 25000) { pulsaJual = pulsaDibeli + 1000; }
else { pulsaJual = pulsaDibeli + 500; }
//Seleksi operator
switch (jenisPulsa)
{
case "AS":
hargaPulsa = pulsaJual;
break;
case "SIMPATI":
hargaPulsa = pulsaJual + 500;
break;
case "XL":
hargaPulsa = pulsaJual - 500;
break;
case "IM3":
if (pulsaJual >= 25000)
{
hargaPulsa = pulsaJual - 500;
}
else { hargaPulsa = pulsaJual - 1000; }
break;
case "MENTARI":
hargaPulsa = pulsaJual + 1000;
break;
}
//Proses
Console.WriteLine();
deposit = deposit - pulsaDibeli;
laba = laba + (hargaPulsa - pulsaDibeli);
//seleksi sisa deposit
if (deposit < pulsaDibeli)
{
Console.WriteLine("Maaf deposit pulsa anda tidak mencukupi transaksi ini");
Console.Write("Masukkan tambahan depoosit : Rp. ");
depositTambah = Convert.ToInt32(Console.ReadLine());
deposit = deposit + depositTambah;
Console.WriteLine();
}
//Output
Console.WriteLine("harga jual : Rp. {0}",
hargaPulsa.ToString());
Console.WriteLine("Deposit sisa : Rp. {0} ",
deposit.ToString());
Console.WriteLine("-----------------------------");
Console.WriteLine();
Console.Write("Apakah ada transaksi lagi? [Y/T] : ");
tanyaUlang = Console.ReadLine();
}
while (tanyaUlang.ToLower() == "y");
Console.WriteLine();
Console.WriteLine("------------------------------");
Console.WriteLine("Sisa deposit : Rp {0}", deposit);
Console.WriteLine("Keuntungan : Rp {0}", laba);
Console.WriteLine("------------------------------");
Console.WriteLine();
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
7. Conver Waktu Uang dan Berat
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Conversi_WaktuUangBerat
{
class Program
{
static void Main(string[] args)
{
int input;
Console.WriteLine(" TUGAS PRAKTIKUM PEMROGRAMAN TERSTRUKTUR \n");
Console.Write("1.Konversi BERAT\n2.Konversi WAKTU\n3.Konversi Mata Uang\nMasukkan Pilihan anda : ");
input = int.Parse(Console.ReadLine());
Console.WriteLine(" ");
switch (input)
{
case 1:
{
Console.Write("Input Nilai TON : ");
Double ton = Double.Parse(Console.ReadLine());
Double kwintal = ton / 100;
Double kg = ton / 1000;
Double kwkg = kwintal / 100;
Console.WriteLine(ton + " \tTon = " + kwintal + "\tktwintal");
Console.WriteLine(ton + " \tTon = " + kg + "\tKg");
Console.WriteLine(kg + " \tKg = " + kwkg + "\tKwintal");
break;
}
case 2:
{
Console.Write("Input Windu : ");
int windu = int.Parse(Console.ReadLine());
int bulan = windu * (8 * 12); // jumlah bulan dalam 1 windu
int jam = windu * ((24 * 30) * (8 * 12)); //windu x jam dalam 1 bulan x jumlah bulan dalam 1 windu
Double buljam = bulan * ((24 * 30) * (8 * 12));
Console.WriteLine(windu + " \tWindu = " + bulan + "\tBulan");
Console.WriteLine(windu + " \tWindu = " + jam + "\tjam");
Console.WriteLine(bulan + " \tBulan = " + buljam + "\tjam");
break;
}
case 3:
{
Console.Write("Input Ringgit : ");
Double ringgit = Double.Parse(Console.ReadLine());
Double peso = ringgit * 14.0881409207;
Double euro = ringgit * 0.250368017812;
Double peeu = peso * 0.0177715441108;
Console.WriteLine(ringgit + "\tRinggit= " + peso + "\tPeso");
Console.WriteLine(ringgit + "\tRinggit= " + euro + "\tEuro");
Console.WriteLine(peso + "\tPeso = " + peeu + "\tEuro");
break;
}
default:
{
Console.WriteLine("PILIHAN TIDAK TERSEDIA ! ");
break;
}
}
Console.ReadLine();
}
}
}
Tidak ada komentar:
Posting Komentar