printlogo
http://www.ethz.ch/index_EN
Welcome
 
print
  

Homework A

1. Go to File->New Module... and choose a create a new Java Module. Set the module name to "Java Primer I" and put it in a directory named
"java1" under your root project directory (e.g.: C:\compmodels\java1)
and tell IDEA to create the directory if it doesn't already exist.

2. Tell IDEA to put the source file in the src directory (default) and the
compiler output path to the classes directory (default).

3. In the Project view, and under Java Primer I->java1->src, right-click
on src and select New->Class. Give it the name TwoPlusTwo and input
the following code:

public class TwoPlusTwo {
    public static void main(String args[]) {
        int a = 2;
        int b = 2;
        int c;
        c = a + b;
        System.out.println("Two plus two is " +c);
    }
}

4. To execute your program, righ-click on TwoPlusTwo and select "Run
TwoPlusTwo.main()" and you should get the following ouptut:

Two plus two is 4

5. Continue similarly with step 3 and 4 for the remaining exercises.

 

Wichtiger Hinweis:
Diese Website wird in älteren Versionen von Netscape ohne graphische Elemente dargestellt. Die Funktionalität der Website ist aber trotzdem gewährleistet. Wenn Sie diese Website regelmässig benutzen, empfehlen wir Ihnen, auf Ihrem Computer einen aktuellen Browser zu installieren. Weitere Informationen finden Sie auf
folgender Seite.

Important Note:
The content in this site is accessible to any browser or Internet device, however, some graphics will display correctly only in the newer versions of Netscape. To get the most out of our site we suggest you upgrade to a newer browser.
More information

© 2014 ETH Zurich | Imprint | Disclaimer | 17 May 2005
top