Core java
19 JanuaryJava program to calculate average marks
In this post, we will see simple java program to find average and percentage marks. We have taken average and percentage of five subject marks below. import java.util.Scanner; public class MarksCalculator { public static void main(String args[]) { int markArray[] = new int[5]; int i; float sum=0; float average, percentage; Scanner scan = new Scanner(System.in); […]
19 JanuaryJava program to make simple calculator
In this post, we will see how to create a simple calculator in java. This calculator program performs 4 basic operatios – Addition, Substraction, Multiplication and division.It uses Switch case to choose operation you want to perform. import java.util.Scanner; public class Calculator { public static void main(String args[]) { float num1, num2, result; char operation, […]
19 JanuaryJava Program to Check Whether a Character is Alphabet or Not
This tutorial provides Java Program to Check Whether a Character is Alphabet or Not. import java.util.Scanner; public class AlphabetFinder { public static void main(String args[]) { char character; Scanner scanner = new Scanner(System.in); System.out.print("Enter a Character : "); character = scanner.next().charAt(0); if((character>='a' && character<='z') || (character>='A' && character<='Z')){ System.out.print(character + " is an alphabet."); }else{ […]
19 JanuaryJava program to check leap year
In this post, we will see how to check leap year. import java.util.Scanner; public class LeapYearFinder { public static void main(String args[]) { int year; Scanner scanner = new Scanner(System.in); System.out.print("Enter Year : "); year = scanner.nextInt(); if((year%4 == 0) && (year%100!=0)){ System.out.print(year+" is a Leap Year"); }else if(year%100 == 0){ System.out.print(year+" is not a […]
19 JanuaryJava Program to check a Character is Vowel or Consonant
In this post, we will see how to check a Character is Vowel or Consonant. You just need to check if character is part of set {a,A,e,E,i,I,o,O,u,U}.If it is part of set then it is Vowel else Consonant. import java.util.Scanner; public class VowelFinder { public static void main(String args[]) { char character; Scanner sacnner = […]
18 JanuaryEven odd program in java
In this post,we will see how to check if number is even odd. It is one of the basic programs of Java programming language. import java.util.Scanner; public class EvenOddFinder { public static void main(String args[]) { int num; Scanner scanner = new Scanner(System.in); System.out.print("Enter a Number : "); num = scanner.nextInt(); if(num%2 == 0) { […]
18 JanuaryJava Program to add two numbers
In this post, we will see how to add two numbers in java. This is the most basic program of java programming language. import java.util.Scanner; public class Calculator { public static void main(String args[]) { int num1, num2, sum; // Taking input from user Scanner scanner = new Scanner(System.in); System.out.print("Enter two numbers : "); num1 […]
02 JanuaryInterface Segregation Principle in java
In this tutorial, we will learn about Interface Segregation Principle.It is one of the SOLID principles. In simple term, Interface Segregation Principle dictates that client should not be forced to implement the methods which it won’t be able to use.You can always throw UnsupportedOperationException from the method which you don’t want to use but it […]
02 JanuaryOpen Closed Principle in Java
In this tutorial, we will learn about Open Closed Design Principle in Java.Open closed principle is one of the SOLID principles. Open Closed Design Principle dictates that “software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification”. This definition was provided by Bertrand Meyer. Once we have written the class and […]