Lesson 3

We already know what is the purpose of  "System.out.println" or "System.out.print". It use to print or display what we want to display.

So now we are going to identify data types in  java  programming language. They are int, double, char, String, float & boolean.

We can understand the diferences among these data types later.

Now I'm going to create a simple calculator.

Try to do this.

public class Cal{
     public static void main(String[] args){
         int a = 10;
         double b = 5;
       
         System.out.println("a+b = "+(a+b));
         System.out.println("a-b = "+(a-b));
         System.out.println("a/b = "+(a/b));
         System.out.println("a*b = "+(a*b));
     }
}

























This time we didn't use user inputs. I'll tell how to get user inputs in next lesson.

Comments

Popular posts from this blog

Lesson 1

Lesson 6 :- Calling a method

Lesson 8 :- Creating an object.