Projektdateien hinzufügen.

This commit is contained in:
2025-05-06 09:21:23 +02:00
parent adba644522
commit dff5de30de
7 changed files with 222 additions and 0 deletions

127
MainWindow.xaml.cs Normal file
View File

@@ -0,0 +1,127 @@
using System;
using System.Windows;
using System.Windows.Controls;
namespace EuroToDollarConverter
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Convert_Click(object sender, RoutedEventArgs e)
{
string eingabe = euroBox.Text;
bool Nummer = true;
foreach (char c in eingabe)
{
if ((c < '0' || c > '9') && c != ',')
{
Nummer = false;
break;
}
}
if (!Nummer)
{
MessageBox.Show("Nur Ziffern und maximal ein Komma erlaubt!");
return;
}
double euro = Convert.ToDouble(eingabe);
double rate = 1;
ComboBoxItem Item = currencyBox.SelectedItem as ComboBoxItem;
if (Item == null)
{
MessageBox.Show("Bitte wählen Sie eine Währung aus.");
return;
}
string Währung = Item.Content.ToString();
switch (Währung)
{
case "Dollar $":
rate = 1.10;
break;
case "Pfund £":
rate = 0.85;
break;
case "Yen ¥":
rate = 160.50;
break;
case "Lira ₺":
rate = 35;
break;
case "Dirham د. إ ":
rate = 10;
break;
default:
MessageBox.Show("Unbekannte Währung ausgewählt.");
return;
}
double result = euro * rate;
dollarBox.Text = result.ToString("F2");
}
}
}