1.Selesih Waktu_0320100029
using System;
namespace Selisih_Waktu_0320100029
{
/// <summary>
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
public struct JAM
{
public int hh;
public int mm;
public int ss;
}
static void Main(string[] args)
{
JAM w1;
JAM w2;
JAM w3;
Console.WriteLine("Jam Mulai Percakapan : ");
w1.hh = Convert.ToInt32(Console.ReadLine());
w1.mm = Convert.ToInt32(Console.ReadLine());
w1.ss = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Jam Selesai Percakapan : ");
w2.hh = Convert.ToInt32(Console.ReadLine());
w2.mm = Convert.ToInt32(Console.ReadLine());
w2.ss = Convert.ToInt32(Console.ReadLine());
w3.mm = 0;
w3.ss = 0;
if(w2.ss>=w1.ss)
{
w3.ss = w2.ss - w1.ss;
}
if(w2.ss<w1.ss)
{
w3.ss = (w2.ss + 60) - w1.ss;
w2.mm = w2.mm - 1;
}
if(w2.mm>w1.mm)
{
w3.mm = w2.mm - w1.mm;
}
if(w2.mm<w1.mm)
{
w3.mm = (w2.mm + 60) - w1.mm;
w2.hh = w2.hh - 1;
}
w3.hh = w2.hh - w1.hh;
Console.WriteLine("\nSelisih Waktu = {0} jam {1} menit {2} detik",w3.hh,w3.mm,w3.ss);
Console.ReadLine();
}
}
}
2. Faktorial_0320100029
using System;
namespace Faktorial_0320100029
{
/// <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 n,fak,k;
Console.Write("Masukkan Angka : ");
n=Convert.ToInt32(Console.ReadLine());
if(n==0)
{
Console.WriteLine("Faktorial Adalah 1");
}
else
{
fak=1;
for(k=1;k<=n;k++)
{
fak=fak*k;
}
Console.WriteLine("Faktorial Adalah {0}",fak);
Console.ReadLine();
}
}
}
}
3. Perbandingan Angka_0320100029
using System;
namespace perbandingan_angka_0320100029
{
/// <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 a,b,c;
Console.Write("A = ? ");
a=Convert.ToInt32(Console.ReadLine());
Console.Write("B = ? ");
b=Convert.ToInt32(Console.ReadLine());
Console.Write("C = ? ");
c=Convert.ToInt32(Console.ReadLine());
if(a<b)
{
if(b<c)
{
Console.WriteLine("Bilangan Terbesar Adalah {0}",c);
}
if(b>c)
{
Console.WriteLine("Bilangan Terbesar Adalah {0}",b);
}
}
if(b<c)
{
if(c<a)
{
Console.WriteLine("Bilangan Terbesar Adalah {0}",a);
}
if(c>a)
{
Console.WriteLine("Bilangan Terbesar Adalah {0}",c);
}
}
Console.ReadLine();
}
}
}
4. Kalkulator_0320100029
using System;
namespace Kalkulator_0320100029
{
/// <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
//
decimal a,b,c;
char operator1;
Console.Write("Angka 1 : ");
a=Convert.ToDecimal(Console.ReadLine());
Console.Write("Operator(+, -, *, /): ");
operator1=Convert.ToChar(Console.ReadLine());
Console.Write("Angka 2 : ");
b=Convert.ToDecimal(Console.ReadLine());
if(operator1=='+')
{
c=a+b;
Console.WriteLine("Jumlah adalah {0} ",c);
}
if(operator1=='-')
{
c=a-b;
Console.WriteLine("Jumlah adalah {0} ",c);
}
if(operator1=='*')
{
c=a*b;
Console.WriteLine("Jumlah adalah {0} ",c);
}
if(operator1=='/')
{
c=a/b;
Console.WriteLine("Jumlah adalah {0} ",c);
}
Console.ReadLine();
}
}
}
using System;
namespace Selisih_Waktu_0320100029
{
/// <summary>
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
public struct JAM
{
public int hh;
public int mm;
public int ss;
}
static void Main(string[] args)
{
JAM w1;
JAM w2;
JAM w3;
Console.WriteLine("Jam Mulai Percakapan : ");
w1.hh = Convert.ToInt32(Console.ReadLine());
w1.mm = Convert.ToInt32(Console.ReadLine());
w1.ss = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Jam Selesai Percakapan : ");
w2.hh = Convert.ToInt32(Console.ReadLine());
w2.mm = Convert.ToInt32(Console.ReadLine());
w2.ss = Convert.ToInt32(Console.ReadLine());
w3.mm = 0;
w3.ss = 0;
if(w2.ss>=w1.ss)
{
w3.ss = w2.ss - w1.ss;
}
if(w2.ss<w1.ss)
{
w3.ss = (w2.ss + 60) - w1.ss;
w2.mm = w2.mm - 1;
}
if(w2.mm>w1.mm)
{
w3.mm = w2.mm - w1.mm;
}
if(w2.mm<w1.mm)
{
w3.mm = (w2.mm + 60) - w1.mm;
w2.hh = w2.hh - 1;
}
w3.hh = w2.hh - w1.hh;
Console.WriteLine("\nSelisih Waktu = {0} jam {1} menit {2} detik",w3.hh,w3.mm,w3.ss);
Console.ReadLine();
}
}
}
2. Faktorial_0320100029
using System;
namespace Faktorial_0320100029
{
/// <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 n,fak,k;
Console.Write("Masukkan Angka : ");
n=Convert.ToInt32(Console.ReadLine());
if(n==0)
{
Console.WriteLine("Faktorial Adalah 1");
}
else
{
fak=1;
for(k=1;k<=n;k++)
{
fak=fak*k;
}
Console.WriteLine("Faktorial Adalah {0}",fak);
Console.ReadLine();
}
}
}
}
3. Perbandingan Angka_0320100029
using System;
namespace perbandingan_angka_0320100029
{
/// <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 a,b,c;
Console.Write("A = ? ");
a=Convert.ToInt32(Console.ReadLine());
Console.Write("B = ? ");
b=Convert.ToInt32(Console.ReadLine());
Console.Write("C = ? ");
c=Convert.ToInt32(Console.ReadLine());
if(a<b)
{
if(b<c)
{
Console.WriteLine("Bilangan Terbesar Adalah {0}",c);
}
if(b>c)
{
Console.WriteLine("Bilangan Terbesar Adalah {0}",b);
}
}
if(b<c)
{
if(c<a)
{
Console.WriteLine("Bilangan Terbesar Adalah {0}",a);
}
if(c>a)
{
Console.WriteLine("Bilangan Terbesar Adalah {0}",c);
}
}
Console.ReadLine();
}
}
}
4. Kalkulator_0320100029
using System;
namespace Kalkulator_0320100029
{
/// <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
//
decimal a,b,c;
char operator1;
Console.Write("Angka 1 : ");
a=Convert.ToDecimal(Console.ReadLine());
Console.Write("Operator(+, -, *, /): ");
operator1=Convert.ToChar(Console.ReadLine());
Console.Write("Angka 2 : ");
b=Convert.ToDecimal(Console.ReadLine());
if(operator1=='+')
{
c=a+b;
Console.WriteLine("Jumlah adalah {0} ",c);
}
if(operator1=='-')
{
c=a-b;
Console.WriteLine("Jumlah adalah {0} ",c);
}
if(operator1=='*')
{
c=a*b;
Console.WriteLine("Jumlah adalah {0} ",c);
}
if(operator1=='/')
{
c=a/b;
Console.WriteLine("Jumlah adalah {0} ",c);
}
Console.ReadLine();
}
}
}