Thursday, October 20, 2011

menambahkan jam dalam c#.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("masukan jam, menit, detik waktu awal");
            int d = int.Parse(Console.ReadLine());
            int e = int.Parse(Console.ReadLine());
            int f = int.Parse(Console.ReadLine());
            Console.WriteLine("masukan jam, menit, detik waktu akhir");
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            Console.WriteLine("waktu awal {0}:{1}:{2}", d, e, f);
            Console.WriteLine("waktu akhir {0}:{1}:{2}", a, b,c);
            if ((c - f) < 0)
            {
                b = b - 1;
                c = c + 60;
                c = c - f;
            }
            else
            c = c - f;
            if ((b - e) < 0)
            {
                a = a - 1;
                b = b + 60;
                b = b - e;
            }
            else
            b = b - e;
            a = a - d;
            Console.WriteLine("waktu hasil {0}:{1}:{2}", a, b, c);

        }
    }
}

No comments:

Post a Comment