Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Brauche Hilfe beim Programmieren in C#

Empfohlene Antworten

Veröffentlicht

Hallo ,

Habe in der Schule ein Übungsblatt bekommen ,jedoch komme ich bei einer Aufgabe nicht weiter ! Also ich muss ein kleine Programm programmieren , das zwei zahlen mit einander + , - , * , / , % nimmt (Einmal als Integer und einmal als Double. Und so habe ich angefangen :

static void Main(string[] args)

{

string aZahl;

string bZahl;

Console.WriteLine("Bitte geben Sie eine Zahl ein !");

aZahl = Console.ReadLine();

Console.WriteLine("Bitte geben Sie eine zweite Zahl ein !");

bZahl = Console.ReadLine();

Console.Clear();

int a = Convert.ToInt32(aZahl);

int b = Convert.ToInt32(bZahl);

Console.WriteLine("Integer");

Console.WriteLine("{0} + {1} = {2}", a, b, a + B);

Console.WriteLine("{0} - {1} = {2}", a, b, a - B);

Console.WriteLine("{0} * {1} = {2}", a, b, a * B);

Console.WriteLine("{0} / {1} = {2}", a, b, a / B);

Console.WriteLine("{0} % {1} = {2}", a, b, a % B);

Das funktioniert schonmal einwandfrei ! Jedoch wenn ich das ganze jetzt in Double convertieren will sagt mir C# , das ich aZahl und bZahl schon mal convertiert habe und ich es nicht nochmal convertieren kann . Jetzt meine Frage : Muss ich aZahl und bZahl in einen String zurück Convertieren und dann nochmal in Double ? Wenn ja mit welchem Befehl mache ich das ?

Denn string aZahl = Convert.ToString(a);

string bZahl = Convert.ToString (B);

funktioniert nicht .

Ich hoffe ihr könnt mir weiterhelfen und bedanke mich schon mal für eure Antworten .

Gruß

Itsjustme

Hat sich erledigt ! Habs rausgefunden ....

double c = Convert.ToDouble(a);

double d = Convert.ToDouble(B);

Console.WriteLine("Double");

Console.WriteLine("{0} + {1} = {2}", c, d, c + d);

Console.WriteLine("{0} + {1} = {2}", c, d, c - d);

Console.WriteLine("{0} + {1} = {2}", c, d, c * d);

Console.WriteLine("{0} + {1} = {2}", c, d, c / d);

Console.WriteLine("{0} + {1} = {2}", c, d, c % d);

Console.ReadLine();

Bitte benutze das nächste mal die Code-Tags. ;)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.