Aykon

Oef5p25

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