Create Software Components 

Using Java Level 2

 

 

Course Info

Scheme

Resources

Tutorials

Java Demos

Utilities

Links


 

 

    Java Exercise

 My Second Application

 

This exercise should really be carried out after reading the First Steps Tutorial and the First Steps Explained

 

  1. Write the following source code in Notepad.

 

/* A program that adds two number together and displays the results on screen */


public class SecondApp {


    public static void main(String[] args) {
        

        int num1;

        int num2;

        int ans;

        num1 = 10;

        num2 = 5;

        ans = num1 + num2;

        System.out.println( "answer = " + ans); 

      
    }

}

 

  1. Save the code as a .java file with the correct name

  2. Compile the code using the javac tool

  3. Run the code using the java compiler

  4. Now change the code so that it subtracts the two numbers instead of adding them. 

 

 

 

  Site Home 

Java Home   

  Forum  

Course Info

Welcome

Overview

Assessment

Qualification

Scheme of Work

Assignments

Resources

Information

Blackboard

Learning Center

Web Materials

Reading

Java Demos

Utilities

Links

Lecture Materials

Tutorials & Notes

Exercises

Activities

Quizzes

 

Site Home

Top

Unit Home

ADR 2002