d2jsp
Log InRegister
d2jsp Forums > Off-Topic > General Chat > Homework Help > Need Help With An Easy Java Question/exercise
Add Reply New Topic New Poll
Member
Posts: 2,134
Joined: Jun 5 2005
Gold: 81.50
Oct 23 2016 11:09am
Topic. Prefer s1 who can speak German but i think it should also be no problem in english. ill pay 500fg at the moment need the help fast please.
I think it will not take long to solve my problem/answer my question if it will take longer ill pay more.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 23 2016 11:41am
Quote
need the help fast please


Post your problem. include whatever code you already have.
Member
Posts: 2,134
Joined: Jun 5 2005
Gold: 81.50
Oct 23 2016 11:53am
i have these 2 programs. at the moment they can add 3 numbers. i need to add another mathematical function to the program.

1:
/**
* Eine Klasse fuer verschiedene Mathematische Funktionen.
*
* @author)
* @version 1.01, 02/2011
*/
public class MyMath {

/**
* Diese Methode berechnet und liefert die Summe von 3 Zahlen vom Typ int.
*
* @param n1
* erste Zahl
* @param n2
* zweite Zahl
* @param n3
* dritte Zahl
* @return die Summe der Zahlen
*/

public static int summiere3Zahlen(int n1, int n2, int n3) {
return n1 + n2 + n3;
}
}

2.
/**
* Testprogramm fuer die Klasse MyMath.
*
* @author
* @version 1.01, 24.02.2011
*/
public class MyMathTest {

/**
* Main-Method zum Starten und Testen der Klasse MyMath. Diese main-Methode
* ist der definierte Einstiegspunkt fuer die Ausfuehrung des Programs und
* erlaubt das Programm zu testen.
*
* @param args
* die Argumente, die man im Allgemeinen fuer die Ausfuehrung
* geben kann
*/
public static void main(String[] args) {
// Statische Methoden der Klasse MyMath testen
System.out.println("Summe von 1,2,3: "
+ MyMath.summiere3Zahlen(1, 2, 3));
System.out.println("Summe von -1,-2,3: "
+ MyMath.summiere3Zahlen(-1, -2, 3));
}
}


my tries:

1.
/**
* Eine Klasse fuer verschiedene Mathematische Funktionen.
*
* @author
* @version 1.01, 02/2011
*/
public class MyMath {

/**
* Diese Methode berechnet und liefert die Summe und die Differenz von 3 Zahlen vom Typ int.
*
* @param n1
* erste Zahl
* @param n2
* zweite Zahl
* @param n3
* dritte Zahl
* @return die Summe und die Differenz der Zahlen
*/

public static int summiere3Zahlen(int n1, int n2, int n3) {
return n1 + n2 + n3;
}

public static int differenziere3Zahlen(int n1, int n2, int n3) {
return n1 - n2 - n3;
}
}

2.
public class MyMathTest {

/**
* Main-Method zum Starten und Testen der Klasse MyMath. Diese main-Methode
* ist der definierte Einstiegspunkt fuer die Ausfuehrung des Programs und
* erlaubt das Programm zu testen.
*
* @param args
* die Argumente, die man im Allgemeinen fuer die Ausfuehrung
* geben kann
*/

public static void main(String[] args) {
// Statische Methoden der Klasse MyMath testen
System.out.println("Summe von 1,2,3: "
+ MyMath.summiere3Zahlen(1, 2, 3));
System.out.println("Summe von -1,-2,3: "
+ MyMath.summiere3Zahlen(-1, -2, 3));
}

public static void main(String[] args) {
System.out.printIn("Differenz von 1,2,3: "
+ MyMath.differenziere3Zahlen(1, 2, 3));
System.out.printIn("Differenz von -1,-2,3: "
+ MyMath.differenziere3Zahlen(-1, -2, 3));
}
}

i tried a lot now but i dont get it to work :/

This post was edited by emotion on Oct 23 2016 11:53am
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 23 2016 12:01pm
Quote (emotion @ Oct 23 2016 01:53pm)
i have these 2 programs. at the moment they can add 3 numbers. i need to add another mathematical function to the program.

1:
Code
/**
* Eine Klasse fuer verschiedene Mathematische Funktionen.
*
* @author)
* @version 1.01, 02/2011
*/
public class MyMath {

/**
* Diese Methode berechnet und liefert die Summe von 3 Zahlen vom Typ int.
*
* @param n1
* erste Zahl
* @param n2
* zweite Zahl
* @param n3
* dritte Zahl
* @return die Summe der Zahlen
*/

public static int summiere3Zahlen(int n1, int n2, int n3) {
return n1 + n2 + n3;
}
}


2.
Code
/**
* Testprogramm fuer die Klasse MyMath.
*
* @author
* @version 1.01, 24.02.2011
*/
public class MyMathTest {

/**
* Main-Method zum Starten und Testen der Klasse MyMath. Diese main-Methode
* ist der definierte Einstiegspunkt fuer die Ausfuehrung des Programs und
* erlaubt das Programm zu testen.
*
* @param args
* die Argumente, die man im Allgemeinen fuer die Ausfuehrung
* geben kann
*/
public static void main(String[] args) {
// Statische Methoden der Klasse MyMath testen
System.out.println("Summe von 1,2,3: "
+ MyMath.summiere3Zahlen(1, 2, 3));
System.out.println("Summe von -1,-2,3: "
+ MyMath.summiere3Zahlen(-1, -2, 3));
}
}



my tries:

1.
Code
/**
* Eine Klasse fuer verschiedene Mathematische Funktionen.
*
* @author
* @version 1.01, 02/2011
*/
public class MyMath {

/**
* Diese Methode berechnet und liefert die Summe und die Differenz von 3 Zahlen vom Typ int.
*
* @param n1
* erste Zahl
* @param n2
* zweite Zahl
* @param n3
* dritte Zahl
* @return die Summe und die Differenz der Zahlen
*/

public static int summiere3Zahlen(int n1, int n2, int n3) {
return n1 + n2 + n3;
}

public static int differenziere3Zahlen(int n1, int n2, int n3) {
return n1 - n2 - n3;
}
}

2.
public class MyMathTest {

/**
* Main-Method zum Starten und Testen der Klasse MyMath. Diese main-Methode
* ist der definierte Einstiegspunkt fuer die Ausfuehrung des Programs und
* erlaubt das Programm zu testen.
*
* @param args
* die Argumente, die man im Allgemeinen fuer die Ausfuehrung
* geben kann
*/

public static void main(String[] args) {
// Statische Methoden der Klasse MyMath testen
System.out.println("Summe von 1,2,3: "
+ MyMath.summiere3Zahlen(1, 2, 3));
System.out.println("Summe von -1,-2,3: "
+ MyMath.summiere3Zahlen(-1, -2, 3));
}

public static void main(String[] args) {
System.out.printIn("Differenz von 1,2,3: "
+ MyMath.differenziere3Zahlen(1, 2, 3));
System.out.printIn("Differenz von -1,-2,3: "
+ MyMath.differenziere3Zahlen(-1, -2, 3));
}
}


i tried a lot now but i dont get it to work :/


offhand looks good to me. can you define "dont get it to work"? is it not compiling? or is it not giving you the results you're expecting? if so, what is your teacher's definition of "difference of three numbers"? first minus second minus third?
Member
Posts: 2,134
Joined: Jun 5 2005
Gold: 81.50
Oct 23 2016 12:03pm
i cant compile it says

C:\de\vfh\gp1\ejp>javac MyMathTest.java
MyMathTest.java:27: error: method main(String[]) is already defined in class MyMathTest
public static void main(String[] args) {
^
MyMathTest.java:28: error: cannot find symbol
System.out.printIn("Differenz von 1,2,3: "
^
symbol: method printIn(String)
location: variable out of type PrintStream
MyMathTest.java:30: error: cannot find symbol
System.out.printIn("Differenz von -1,-2,3: "
^
symbol: method printIn(String)
location: variable out of type PrintStream
3 errors


i also tried it this way:

1:
public class MyMathTest {

/**
* Main-Method zum Starten und Testen der Klasse MyMath. Diese main-Methode
* ist der definierte Einstiegspunkt fuer die Ausfuehrung des Programs und
* erlaubt das Programm zu testen.
*
* @param args
* die Argumente, die man im Allgemeinen fuer die Ausfuehrung
* geben kann
*/

public static void main(String[] args) {
// Statische Methoden der Klasse MyMath testen
System.out.println("Summe von 1,2,3: "
+ MyMath.summiere3Zahlen(1, 2, 3));
System.out.println("Summe von -1,-2,3: "
+ MyMath.summiere3Zahlen(-1, -2, 3));
System.out.printIn("Differenz von 1,2,3: "
+ MyMath.differenziere3Zahlen(1, 2, 3));
System.out.printIn("Differenz von -1,-2,3: "
+ MyMath.differenziere3Zahlen(-1, -2, 3));
}
}


then i get:
C:\de\vfh\gp1\ejp>javac MyMathTest.java
MyMathTest.java:25: error: cannot find symbol
System.out.printIn("Differenz von 1,2,3: "
^
symbol: method printIn(String)
location: variable out of type PrintStream
MyMathTest.java:27: error: cannot find symbol
System.out.printIn("Differenz von -1,-2,3: "
^
symbol: method printIn(String)
location: variable out of type PrintStream
2 errors


This post was edited by emotion on Oct 23 2016 12:07pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 23 2016 12:06pm
Quote (emotion @ Oct 23 2016 02:03pm)
i cant compile it says

C:\de\vfh\gp1\ejp>javac MyMathTest.java
MyMathTest.java:27: error: method main(String[]) is already defined in class MyMathTest
public static void main(String[] args) {
^
MyMathTest.java:28: error: cannot find symbol
System.out.printIn("Differenz von 1,2,3: "
^
symbol: method printIn(String)
location: variable out of type PrintStream
MyMathTest.java:30: error: cannot find symbol
System.out.printIn("Differenz von -1,-2,3: "
^
symbol: method printIn(String)
location: variable out of type PrintStream
3 errors


it tells you the problem:

Quote
MyMathTest.java:27: error: method main(String[]) is already defined in class MyMathTest


just combine your methods into one that tests both the sum and difference:

Code
public class MyMathTest {

/**
* Main-Method zum Starten und Testen der Klasse MyMath. Diese main-Methode
* ist der definierte Einstiegspunkt fuer die Ausfuehrung des Programs und
* erlaubt das Programm zu testen.
*
* @param args
* die Argumente, die man im Allgemeinen fuer die Ausfuehrung
* geben kann
*/

public static void main(String[] args) {
// Statische Methoden der Klasse MyMath testen
System.out.println("Summe von 1,2,3: "
+ MyMath.summiere3Zahlen(1, 2, 3));
System.out.printIn("Differenz von 1,2,3: "
+ MyMath.differenziere3Zahlen(1, 2, 3));
}
}
Member
Posts: 2,134
Joined: Jun 5 2005
Gold: 81.50
Oct 23 2016 12:08pm
did you see my edit? i think thats what you say
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 23 2016 12:13pm
Quote (emotion @ Oct 23 2016 02:08pm)
did you see my edit? i think thats what you say


you misspelled `printin` with the letter `i` as in `eye`
Member
Posts: 2,134
Joined: Jun 5 2005
Gold: 81.50
Oct 23 2016 12:17pm
Quote (carteblanche @ 23 Oct 2016 20:13)
you misspelled `printin` with the letter `i` as in `eye`



as i said easy money ;D
thx for your help!

tc

This post was edited by emotion on Oct 23 2016 12:17pm
Go Back To Homework Help Topic List
Add Reply New Topic New Poll