JasperHuyghe

Lagenmodel-oef5-Winform

Mar 14th, 2023
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 KB | None | 0 0
  1. Form1.cs
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11.  
  12. namespace OefeninfenLagenForms
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         public Form1()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.  
  21.         private void Berekenknop_Click(object sender, EventArgs e)
  22.         {
  23.             Business b1 = new Business();
  24.            
  25.             MessageBox.Show(Convert.ToString(b1.berekenTeBetalen(Convert.ToDouble(txtBedraginv.Text))));
  26.            
  27.         }
  28.     }
  29. }
  30.  
  31. Business.cs
  32. using System;
  33. using System.Collections.Generic;
  34. using System.Linq;
  35. using System.Text;
  36. using System.Threading.Tasks;
  37.  
  38. namespace OefeninfenLagenForms
  39. {
  40.     class Business
  41.     {
  42.         private double bedrag;
  43.         public double Bedrag
  44.         {
  45.             get { return bedrag; }
  46.             set { bedrag = value; }
  47.         }
  48.         public double berekenTeBetalen(double pbedrag)
  49.         {
  50.             double korting = 0.0;
  51.             if (pbedrag > 0)
  52.             {
  53.                 if (pbedrag < 50)
  54.                 {
  55.                     korting = 0.025;
  56.                 }
  57.                 else if (pbedrag < 100)
  58.                 {
  59.                     korting = 0.05;
  60.                 }
  61.                 else if (pbedrag <200)
  62.                 {
  63.                     korting = 0.10;
  64.  
  65.                 }
  66.                 else
  67.                 {
  68.                     korting = 0.20;
  69.                 }
  70.                 return pbedrag - (pbedrag * korting );
  71.             }
  72.             return 0;
  73.         }
  74.     }
  75. }
  76.  
Advertisement
Add Comment
Please, Sign In to add comment