Posts

Showing posts with the label Tutorial

Java Tutorial 12 --- "Switch Case Statements"

Image
 Java Tutorial 12 --- "Switch Case Statements" DOC ---  CODE --- package com.company ; import java.util.Scanner ; public class Tut12 { public static void main (String[] args) { // Switch Case Statements System. out .println( "Please enter your Number" ) ; Scanner sc = new Scanner(System. in ) ; int number = sc.nextInt() ; switch (number) { case 18 -> System. out .println( "You have won nothing but you have to Pay Double" ) ; case 7 -> System. out .println( "You have won the Double Prize" ) ; case 777 -> System. out .println( "You have won the MEGA Prize" ) ; case 13 -> System. out .println( "You cant win any prizes for one year" ) ; } if (number>= 60 ){ System. out .println( "Congratulations! You have won the Platinum Prize " ) ; } else if (number>= 50 ){ ...

Java Tutorial 11 --- "Relational and Logical Operators"

Image
 Java Tutorial 11 --- "Relational and Logical Operators" DOC ---  CODE ---  package com.company ; public class Tut11 { public static void main (String[] args) { // Relational and Logical Operators System. out .println( "For Logical AND....." ) ; Boolean a = true; Boolean b = true; Boolean c = true; if (a && b && c){ System. out .println( "Y" ) ; } else { System. out .println( "N" ) ; } System. out .println( "For Logical OR....." ) ; Boolean d = true; Boolean e = false; Boolean f = true; if (a && b || c){ System. out .println( "Y" ) ; } else { System. out .println( "N" ) ; } System. out .println( "For logical NOT...." ) ; System. out .println( "Not A is - " + !a) ; Sy...

Java Tutorial 10 --- "If-else Statement in Java"

Image
 Java Tutorial 10 --- "If-else Statement in Java" DOC ---  CODE ---  package com.company ; import java.util.Scanner ; public class Tut10 { public static void main (String[] args) { // If-else Statement in Java System. out .println( "Enter your age --- " ) ; Scanner sc = new Scanner(System. in ) ; // int age = 20; int age = sc.nextInt() ; //Using Input function (Scanner class) if (age>= 18 ){ System. out .println( "Yes boy you can drive." ) ; } else { System. out .println( "No boy you cannot drive, not yet." ) ; } } }

Java Tutorial 8 --- "Introduction to Strings"

Image
 Java Tutorial 8 --- "Introduction to Strings" CODE --- package com.company ; import java.util.Scanner ; public class Tut8 { public static void main (String[] args) { // Introduction to String // String name = new String("Saswata"); String name = "Saswata" ; // Strings are immutable System. out .print( "My name is " ) ; //print doesn't print a new line after print. System. out .println(name) ; //println does print a new line after print. int a = 5 ; float b = 6.5545f ; System. out .printf( "The value of a is %d and the value of b is %f" , a , b) ; System. out .println() ; System. out .printf( "The value of a is %d and the value of b is %.2f" , a , b) ; System. out .println() ; System. out .printf( "The value of a is %d and the value of b is %10.2f" , a , b) ; System. out .println() ; System. out .print...

Java Tutorial 7 --- "Data Type of Expressions & Increment/Decrement Operators"

Java Tutorial 7 --- "Data Type of Expressions & Increment/Decrement Operators" package com.company ; public class Tut7 { public static void main (String[] args) { // Data Type of Expressions & Increment/Decrement Operators /* b+s = int | b = byte s+i = int | s = short l+f = float | i = integer i+f = float | l = long c+i = int | f = float c+s = int | d = double l+d = double | c = character f+d = double | */ // int i = 45 + 5; // System.out.println(i); // float f = 6.5f + 2; // System.out.println(f); // Increment & Decrement Operators int i = 50 ; System. out .println(i++) ; //First use i then increment System. out .println(i) ; System. out .println(++i) ; // First increment i then use Sys...