Home

Published

- 2 min read

CPE263 Week Homework Pair

img of CPE263 Week Homework Pair

Week 3 Homework Pair


Code

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

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

        private void btnCal_Click(object sender, EventArgs e)
        {
            int pre, late, total, cal;
            string txt = "";

            pre = Convert.ToInt32(txtPrevious.Text);
            late = Convert.ToInt32(txtLatest.Text);
            total = late-pre;

            if (total <= 10)
                cal = total * 5;
            else if (total <= 5)
                cal = (10 * 5) + ((total - 10) * 6);
            else
                cal = (10 * 5) + (40 * 6) + ((total - 50) * 7);

            txt = $"Previous\t:\t{pre}\n" +
                $"Latest\t:\t{late}\n" +
                $"Total\t:\t{total}\n" +
                $"Pay\t:\t{cal}";

            MessageBox.Show(txt);
        }
    }
}

Dowload here!


Code 2

   Home work pair
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            double w, h ,cal;
            w = Convert.ToDouble(txtWeight.Text);
            h = Convert.ToDouble(txtHeigh.Text);
            if (radFemale.Checked == true)
            {
                cal = h - 110;
                if (cal < w)
                {
                    MessageBox.Show("อ้วน");
                }
                else
                {
                    MessageBox.Show("ไม่อ้วน");
                }
            }
            if (radMale.Checked == true)
            {
                cal = h - 100;
                if (cal < w)
                {
                    MessageBox.Show("อ้วน");
                }
                else
                {
                    MessageBox.Show("ไม่อ้วน");
                }
            }
        }
    }
}