Sabtu, 23 Januari 2010

Persiapan UAS Praktek C# : Mencari Genap dan bilangan terbesar (OOP)











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

using System.Windows.Forms;

namespace aplikasi1
{
    public class org_tua
    {
        private int[] angka = new int[101];
     
        protected int dat;
        protected void x_angka (int x, int y)
        {
            angka[x] = y + y;        
        }
        protected int y_angka(int z)
        {
            return angka[z];
        }
       
        public virtual void GetDat()
        {
            Console.Clear();
            Console.Write("Berapa Banyak Data [1-100] : ");
        }

    }

    class Anak_data : org_tua
    {
        genap g = new genap();

        public override void GetDat()
        {
            base.GetDat();
            g.cek_num(Console.ReadLine(),1);
            base.dat = g.ambil_num;
            Console.WriteLine();
            Console.WriteLine("Masukkan Angka 1-10 :");
            int i =1;
            while((i<=base.dat)&&(base.dat<=100)){
                Console.Write("Data ke-{0} : ", i);
                g.cek_num(Console.ReadLine(),2);
                base.x_angka(i, g.ambil_num);

                if (g.ambil_num <= 10 && g.ambil_num >= 1)
                {
                    Console.Write("{0} + {1} = {2} ", g.ambil_num, g.ambil_num, base.y_angka(i));
                    i += 1;
                }
                Console.WriteLine();
            }

        } 

       

        public void bil_genap()
        {
            try
            {
                if (base.dat > 0)
                {
                    int j;
                    for (j = 1; j <= base.dat; j++)
                    {
                        Console.Write("{0}. Penjumlahan genap sampai {1} = ", j, base.y_angka(j));
                        g.cetak(this, j);
                        Console.WriteLine();
                    }
                }
                else
                {
                    throw new Exception("Tidak Ada Data!.");
                }
            }
            catch (Exception warning)
            {
                MessageBox.Show(warning.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }

        public void bil_max()
        {
            try
            {
                if (base.dat > 0)
                {
                    int j;
                    Console.WriteLine("Data : ");
                    for (j = 1; j <= base.dat; j++)
                    {
                        Console.WriteLine("Data Ke-{0} = {1}", j, base.y_angka(j));
                    }

                    Console.WriteLine();
                    Console.Write("Bilangan Terbesar Dari Data Di Atas Adalah : ");
                    g.max(this, base.dat);
                }
                else
                {
                    throw new Exception("Tidak Ada Data!.");
                }
            }
            catch (Exception warning)
            {
                MessageBox.Show(warning.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }


        public int z_angka(int z)
        {

            return base.y_angka(z);
          
        }



    }


    class genap
    {
        private int num;
        public void cek_num(String s, byte pil)
        {
            try
            {
                num = 0;
                bool cek = int.TryParse(s, out num);
                if ((cek == false))
                {                  
                    throw new Exception("Data yang anda masukkan tidak valid. Lihat Kembali Ketentuannya.");
                }
                else
                {
                    if ((pil == 1) && ((num < 1) && (num > 100)))
                    {
                        throw new Exception("Data yang anda masukkan tidak valid. Lihat Kembali Ketentuannya.");
                      
                    }
                    else if ((pil == 2) && ((num < 1) && (num > 10)))
                    {
                        throw new Exception("Data yang anda masukkan tidak valid. Lihat Kembali Ketentuannya.");
               
                    }
                   
                }
            }
            catch (Exception warning)
            {
                MessageBox.Show(warning.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
       
        public int ambil_num
        {
            get
            {return num;}
        }

        public void cetak(Anak_data ad, int j)
        {
            int temp=0;
            for (int k = 1; k <= ad.z_angka(j); k++)
            {
                if (k % 2 == 0)
                {
                    temp = temp + k;
                    if (k == ad.z_angka(j) || k == ad.z_angka(j) - 1)
                    {
                        Console.Write("{0} = {1} ", k, temp);
                    }
                    else
                    {
                        Console.Write("{0} + ", k);
                    } 
                }
            }
        }
        private int[] angka_max = new int[101];
     
        public void max(Anak_data ad, int dat)
        {
            int temp;
           
            temp = ad.z_angka(1);
            int i = 1;
            angka_max[i] = 1;
            for (int k = 2; k <= dat; k++)
            {               
                if (ad.z_angka(k) >= temp)
                {

                    if (ad.z_angka(k) == temp)
                    {
                        i += 1;
                        angka_max[i] = k;
                    }
                    else
                    {
                        temp = ad.z_angka(k);
                        i = 1;
                        angka_max[i] = k;
                    }
                }
            }
            Console.Write("{0}", temp);
            Console.WriteLine();
            Console.Write("Ada Pada Data Ke - ");
            for (int k = 1; k <= i; k++)
            {
                if (k > 1)
                {
                    if (k == i)
                    {
                        Console.Write(" dan Ke - {0}", angka_max[k]);
                    }
                    else
                    {
                        Console.Write(", Ke - {0},", angka_max[k]);
                    }
                }
                else
                {
                    Console.Write("{0}", angka_max[k]);
                }
            }
        }
    }

    class umum
    {

        Anak_data ad = new Anak_data();

        public void menu()
        {
            String pilihan = "";

            do
            {
                try
                {
                    Console.Clear();
                    Console.WriteLine("Menu");
                    Console.WriteLine("A.Input Data");
                    Console.WriteLine("B.Genap");
                    Console.WriteLine("C.Bilangan Terbesar");
                    Console.WriteLine("D.Biodata Pemrogram");
                    Console.WriteLine("E.Exit");
                    Console.Write("Pilih menu : ");
                    pilihan = Console.ReadLine();
                    decimal num = 0;
                    bool cek = decimal.TryParse(pilihan, out num);
                    if (cek == true)
                    {
                        throw new Exception("Anda Memasukkan Angka ");
                    }


                    switch (pilihan.ToUpper())
                    {
                        case "A":
                            ad.GetDat();
                            Console.ReadLine();
                            break;

                        case "B":
                            Console.Clear();
                            ad.bil_genap();

                            Console.ReadLine();
                            break;

                        case "C":
                            Console.Clear();
                            ad.bil_max();

                            Console.ReadLine();
                            break;

                        case "D":
                            Console.Clear();
                            Console.WriteLine("Fahmi Faizal");
                            Console.WriteLine("juventini_11ind@yhoo.com");
                            Console.WriteLine("© 2010 ASISTEN-2007. All rights reserved.");
                            Console.ReadLine();
                            break;

                        case "E":
                            throw new Exception("Terimakasih");
                        default:                            
                            throw new Exception("Maaf, pilihan anda Salah!!");
                    }


                }
                catch (Exception warning)
                {
                    MessageBox.Show(warning.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            } while (pilihan.ToUpper() != "E");

        }

    }

}

---------------------------------------------------------------------------------------------------------------------------------
//MENU PROGRAM PEMANGGIL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace aplikasi1
{
   
    class kelas_utama
    {
        static void Main()
        {
            umum u = new umum();
            u.menu();
        }
    }
}

5 komentar:

Anonim mengatakan...

Make room the beast with two backs casinos? scrutinize this inexperienced [url=http://www.realcazinoz.com]online casinos[/url] pilot and fake online casino games like slots, blackjack, roulette, baccarat and more at www.realcazinoz.com .
you can also inhibit our fresh [url=http://freecasinogames2010.webs.com]casino[/url] direct at http://freecasinogames2010.webs.com and be heir to in realized spondulix !
another modern [url=http://www.ttittancasino.com]casino spiele[/url] position is www.ttittancasino.com , in the course of german gamblers, retrieve well-wishing online casino bonus.

Anonim mengatakan...

Hey, Good night.
I like www.blogger.com because I learned a lot here. Now it's time for me to pay back.
Why I want to post this guide on this of www.blogger.com is to help people solve the same problem.
Please let me know if it is unacceptable here.
Here is the guide, hope it would do people a favor.

Next generation Video - is HD difficult?
So what is HD? High-definition (HD) video generally refers to any video system of higher resolution than standard-definition (SD) video, most commonly at display resolutions of 1280×720 (720p) or 1920×1080 (1080i or 1080p). High-definition video is more than just a name which indicates that an image has a higher resolution than previous video forms, rather HD is a specific technical specification that all major hardware manufacturers and software developers have agreed upon for the future of film, TV, video and broadcasting. Video is moving to high definition faster than a dog to a doughnut.
If you have recently purchased an HD camcorder like me, you may have encountered some difficulty to download and edit HD video files as well. Most of the latest camcorders, especially those that record to SD, SDHC, or Hard-Drive media, are encoded in AVCHD format. Until recently, many of the consumer versions of editing software applications did not support AVCHD, but now there are a few that are starting to support it and can import AVCHD files directly from popular camcorders. Some can even open and edit HD files already copied to a hard disk.
One of these applications is Video Studio Pro X2 from Core which has been upgraded recently. As it claims, it can edit HD video quickly and smoothly with enhanced Smart Proxy editing, and with this tool we can import HDV, AVCHD, BDMV (files from Blu-ray camcorders) camcorders for editing and output as BDAV, BDMV, and AVCHD formats. I honestly have to say that if you need a video editing software to support your HD camcorder, Video studio is probably the one you are looking for.
What I need to mention however, is that a few days before Video studio was upgraded to support HD, Xilisoft Video Converter had already added the HD video converting to its 5th edition. The tool now serves me to convert HD files and simply edit HD video for my PS3 with end to end supporting of most HD formats like AVCHD, MKV, HD WMV, etc. And if we can say that the features of Video studio are for semi-pros than it is also right to say that the Video Converter is for zero-pros.




Resource:
[url=http://www.dvd-to-avi-converter.net]DVD to AVI Converter[/url]
[url=http://www.dvd-copier.net]DVD Clone[/url]
[url=http://www.topvideoconverter.com/best-audio-converter-review/]audio converter review[/url]
[url=http://www.totalsofts.com/iphone_video_converter_iphone_ringtone_maker.php]video to iPhone converter[/url]
[url=http://www.ipod-to-mac.net]mac ipod rip[/url]

Anonim mengatakan...

simply mountain dew guaranteed to call for upon you knowledge large! Our all imbecile intermingle of herbs and aminos is Dr. formulated and proven to commend vacation, redress mentally disturbing prime bottom and equitable backlash your sagacity!


[url=http://minichill.com]Energy Drink[/url]
[url=http://minichill.com]Energy Drinks[/url]
[url=http://minichill.com]Stress Relief[/url]

[url=http://minichill.com/home/index.html]facebook[/url]
[url=https://www.getreversemortgagehelp.com/]best reverse mortgage[/url]


[url=http://minichill.com/5%20hour%20energy.html]best energy drink[/url]


[url=http://minichill.com/5%20hour%20energy.html]best energy drink[/url]
[url=http://minichill.com/lab/relaxation/index.html]Valerian Root[/url]
[url=http://minichill.com/lab/happiness/index.html]Valerian Root[/url]
[url=http://minichill.com/lab/focus/index.html]L-Theanine[/url]
[url=http://minichill.com/lab/anti-anxiety/index.htmll]GABA[/url]
[url=http://minichill.com/lab/anti-anxiety/index.htmll]Gamma Aminobutyric Acid [/url]


vast Julian with Grub and Soften you can existent a well-behaved life. I procedure in actually, it's terrified so log a materialize on and ry it, do it now!
Mini Chill? contains a reasonable coalesce of herbs and amino acids called Relarian?, that has been proven, in published clinical trials not in unison to surely go all out against burden and chew equal's nails, but to in actuality redact your air and masher flexure make the familiarity of! Mini Undistinguished doesn?t concern drowsiness, so whether you?re in the bull's-eye of a stressful hour at job or enjoying a generalized open reticent with your friends, Mini Chill? is guaranteed to adjust your day.



[url=http://minichill.com/ChillRecipes.html]alcohol poisening[/url]
[url=http://routeworldbrokers.com/]Distribution businesses[/url]
[url=http://routeworldbrokers.com/]Business appraisals[/url]
[url=http://minichill.com/ChillRecipes.html]medical marijuana evaluation[/url]

[url=http://minichill.com/ChillRecipes.html]alcohol treatments[/url]

[url=http://www.finmedsys.com/]medical billing services[/url]
[url=http://www.finmedsys.com/]medical billing services[/url]
[url=http://www.finmedsys.com/]medical billing solutions[/url]

[url=http://www.thestatecolumn.com/]state politics[/url]
[url=http://minichill.com/lab/relaxation/index.html]be relax[/url]

[url=http://minichill.com/lab/relaxation/index.html]relax cool red[/url]
[url=http://minichill.com/ChillRecipes.html]medical marijuana physician[/url]
[url=http://minichill.com/ChillRecipes.html]marijuana helps[/url]

Anonim mengatakan...

You really are a very intelligent individual!


my website is Korean Words .Also welcome you!

Anonim mengatakan...

I love erwin680.blogspot.com! Here I always find a lot of helpful information for myself. Thanks you for your work.
Webmaster of http://loveepicentre.com and http://movieszone.eu
Best regards