<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[4 Grundrechenarten leserlicher]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>brauche dringend Hilfe bei folgendem Code:</p>
<p>Der markierte Code-Schnippsel soll ungefähr so aussehen, habe ich mir gedacht.</p>
<p>Die Frage lautet:</p>
<p>Ein Programm fordert zwei Zahlen an und verknüpft diese nach den Regeln der 4 Grundrechenarten miteinander.<br />
Folgendes Struktogramm liegt mir zugrunde:</p>
<p>Class: Zahlen<br />
Eigenschaften: zahl1, zahl2, ergebnis<br />
Konstruktor initialisiert: (z = 1.0, n = 3.0, e = 1.0)<br />
Variable &quot;arith&quot; vom Typ &quot;Zahlen&quot; definieren<br />
Konstruktor: zahl1 = z, zahl2 = n, ergebnis = e</p>
<p>Methode: plus<br />
minus<br />
mal<br />
durch<br />
eingabe</p>
<p>In der Methode durch() soll eine Division durch Null abgefangen werden,<br />
indem dem Nenner dem Nenner der Wert 1 gegeben wird.<br />
Mittels einer Textausgabe:&quot;Zahl 2 darf nicht Null sein&quot;<br />
soll auf eine fehlerhafte Eingabe des Nenners hingewiesen werden.</p>
<p>Alle Methoden mit Ausnahme der oben beschriebenen sollen als Inline-Methoden angelegt werden.</p>
<p>Die Textausgabe soll so aussehen:</p>
<p>Zahl 1 = 1<br />
Zahl 2 = 2</p>
<p>1 + 3 = 4<br />
1 - 3 = -2<br />
1 * 3 = 3<br />
1 / 4 = 0.333333<br />
Bitte Taste druecken</p>
<pre><code class="language-cpp">C/C++ Code: 
#include &lt;stdio.h&gt; 
#include &lt;conio.h&gt; 
#include &lt;iostream.h&gt; 

class Zahlen 
{ 
private: 
float zahl1; 
float zahl2; 
float ergebnis; 
public : 
void plus(void); //INLINE FUNKTIONEN 
void minus(void); 
void mal(void); 
void durch(void); 
void eingabe(void); 

void print(void); 
Zahlen(float zahl1 = 1.0, 
float zahl2 = 3.0, 
float ergebnis = 1.0) 

/*void minus(void) 
{ 
cout &lt;&lt; zahl1 &lt;&lt; &quot; - &quot; &lt;&lt; zahl2 &lt;&lt; &quot; = &quot; &lt;&lt; ergebnis &lt;&lt; endl; 
ergebnis = zahl1 - zahl2; 
}*/ 
{ 
zahl1 = z; 
zahl2 = n; 
ergebnis = e; 
}; 

/* ****************Haupfunktion****************************** */ 
void main(void) 
{ 
Rechnen arith(1.0, 3.0); 
arith.print 
getch(); 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/143161/4-grundrechenarten-leserlicher</link><generator>RSS for Node</generator><lastBuildDate>Wed, 02 Sep 2026 03:07:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/143161.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 05 Apr 2006 21:03:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 4 Grundrechenarten leserlicher on Wed, 05 Apr 2006 21:03:53 GMT]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>brauche dringend Hilfe bei folgendem Code:</p>
<p>Der markierte Code-Schnippsel soll ungefähr so aussehen, habe ich mir gedacht.</p>
<p>Die Frage lautet:</p>
<p>Ein Programm fordert zwei Zahlen an und verknüpft diese nach den Regeln der 4 Grundrechenarten miteinander.<br />
Folgendes Struktogramm liegt mir zugrunde:</p>
<p>Class: Zahlen<br />
Eigenschaften: zahl1, zahl2, ergebnis<br />
Konstruktor initialisiert: (z = 1.0, n = 3.0, e = 1.0)<br />
Variable &quot;arith&quot; vom Typ &quot;Zahlen&quot; definieren<br />
Konstruktor: zahl1 = z, zahl2 = n, ergebnis = e</p>
<p>Methode: plus<br />
minus<br />
mal<br />
durch<br />
eingabe</p>
<p>In der Methode durch() soll eine Division durch Null abgefangen werden,<br />
indem dem Nenner dem Nenner der Wert 1 gegeben wird.<br />
Mittels einer Textausgabe:&quot;Zahl 2 darf nicht Null sein&quot;<br />
soll auf eine fehlerhafte Eingabe des Nenners hingewiesen werden.</p>
<p>Alle Methoden mit Ausnahme der oben beschriebenen sollen als Inline-Methoden angelegt werden.</p>
<p>Die Textausgabe soll so aussehen:</p>
<p>Zahl 1 = 1<br />
Zahl 2 = 2</p>
<p>1 + 3 = 4<br />
1 - 3 = -2<br />
1 * 3 = 3<br />
1 / 4 = 0.333333<br />
Bitte Taste druecken</p>
<pre><code class="language-cpp">C/C++ Code: 
#include &lt;stdio.h&gt; 
#include &lt;conio.h&gt; 
#include &lt;iostream.h&gt; 

class Zahlen 
{ 
private: 
float zahl1; 
float zahl2; 
float ergebnis; 
public : 
void plus(void); //INLINE FUNKTIONEN 
void minus(void); 
void mal(void); 
void durch(void); 
void eingabe(void); 

void print(void); 
Zahlen(float zahl1 = 1.0, 
float zahl2 = 3.0, 
float ergebnis = 1.0) 

/*void minus(void) 
{ 
cout &lt;&lt; zahl1 &lt;&lt; &quot; - &quot; &lt;&lt; zahl2 &lt;&lt; &quot; = &quot; &lt;&lt; ergebnis &lt;&lt; endl; 
ergebnis = zahl1 - zahl2; 
}*/ 
{ 
zahl1 = z; 
zahl2 = n; 
ergebnis = e; 
}; 

/* ****************Haupfunktion****************************** */ 
void main(void) 
{ 
Rechnen arith(1.0, 3.0); 
arith.print 
getch(); 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1031442</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031442</guid><dc:creator><![CDATA[Renate]]></dc:creator><pubDate>Wed, 05 Apr 2006 21:03:53 GMT</pubDate></item><item><title><![CDATA[Reply to 4 Grundrechenarten leserlicher on Wed, 05 Apr 2006 22:08:58 GMT]]></title><description><![CDATA[<pre><code>[cpp]

#include &lt;stdio.h&gt;
#include &lt;conio.h&gt;
#include &lt;iostream.h&gt;

class Zahlen
{
private:
  float zahl1;
  float zahl2;
  float ergebnis;
public :

void plus(void)
{
  ergebnis = zahl1 + zahl2; 
  cout &lt;&lt; zahl1 &lt;&lt; &quot; + &quot; &lt;&lt; zahl2 &lt;&lt; &quot; = &quot; &lt;&lt; ergebnis &lt;&lt; endl;    
}; 
void minus(void)
{
  ergebnis = zahl1 - zahl2; 
  cout &lt;&lt; zahl1 &lt;&lt; &quot; - &quot; &lt;&lt; zahl2 &lt;&lt; &quot; = &quot; &lt;&lt; ergebnis &lt;&lt; endl;  
};
void mal(void);
{
  ergebnis = zahl1 * zahl2; 
  cout &lt;&lt; zahl1 &lt;&lt; &quot; * &quot; &lt;&lt; zahl2 &lt;&lt; &quot; = &quot; &lt;&lt; ergebnis &lt;&lt; endl;  
};

void durch(void);
{
  ergebnis = zahl1 / ( (zahl2==0)?1:zahl2 ); 
  if (zahl2==0)
    cout &lt;&lt; &quot;zahl2 darf nicht 0 sein&quot; &lt;&lt; endl;
  else    
    cout &lt;&lt; zahl1 &lt;&lt; &quot; / &quot; &lt;&lt; zahl2 &lt;&lt; &quot; = &quot; &lt;&lt; ergebnis &lt;&lt; endl;  
};

void eingabe(void);

void print(void)
{
  cout &lt;&lt; &quot;Zahl1 = &quot; &lt;&lt; zahl1 &lt;&lt; endl;
  cout &lt;&lt; &quot;Zahl2 = &quot; &lt;&lt; zahl2 &lt;&lt; endl;
};

Zahlen(float z = 1.0, float n = 3.0,float e = 1.0)
{
zahl1 = z;
zahl2 = n;
ergebnis = e;
};

/* ****************Haupfunktion****************************** */
void main(void)    // void falsch int main(void) ist richtig
{
Rechnen arith(1.0, 3.0);  // Rechnen?? --&gt; Zahlen arith(1.0, 3.0);
arith.print   // ?? arith.print();
getch();
}  

[/cpp]
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1031482</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031482</guid><dc:creator><![CDATA[frodo1]]></dc:creator><pubDate>Wed, 05 Apr 2006 22:08:58 GMT</pubDate></item></channel></rss>