Wednesday, 10 July 2013

Basic Arithmetic


ASSIGNMENT 2: PRINT YOUR CALCULATED VALUE WITH A TEXT:

public class MyFirstProject {

 public static void main(String args[]){
        int a = 5;
        int b = 5;
        int x = a + b;
       
        System.out.println("Your Total sum is: => " + x); 

// Your Total sum is: => 1     
}
}



ASSIGNMENT 1: PRINT YOUR CALCULATED VALUE:
 
public class MyFirstProject {

 public static void main(String args[]){
        int a = 5;
        int b = 5;
        int x = a + b;
       
        System.out.println("x"); // OR;
        System.out.println(a + b);
        System.out.println(a - b);
        System.out.println(a * b);
        System.out.println(a / b);
        System.out.println(a % b); // Remainder (%)
}

}


No comments:

Post a Comment