2 Mart 2015 Pazartesi

Kuyu Problemi Algoritması ve C# Kodu

Soru: Bir Kömür Kuyusu 9.80 metredir. En dipte Kepçeye 2586 kg kömür yüklenmektedir. Kepçe yukarı çekilirken her 40 metrede 58 kg kömür dökülmektedir. Kepçe yukarı çıktığında Kaç kg kömür kalır?

1. Başla


2. yukseklik = 980; //cm
    kg = 2586;
    dokulenyukseklik = 4000; //cm
    sonuc = 0;
    bolum = 0;

3. bolum = yukseklik / dokulenyukseklik;

4. sonuc = kg - bolum;

5. sonuc 'u ekrana yazdır.

6. Bitir




C# Kodları

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace komur_kuyusu
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        double yukseklik = 980;//cm hesabı
        double kg = 2586;
        int dokulenyukseklik = 4000;//cm hesabı
        double sonuc = 0, bolum = 0;

        private void button1_Click(object sender, EventArgs e)
        {
            bolum=yukseklik/dokulenyukseklik;
            sonuc = kg - bolum;
            MessageBox.Show("Kepçe Yüzeye Çıktığında "+ sonuc +" Kg Kalır.");
        }
    }

}

Paylaş:

0 yorum:

Yorum Gönder

Popüler

Son

Kategoriler