• Image
    22 January

    Convert celsius to fahrenheit in java

    In this tutorial, we will see simple java program to convert celsius to fahrenheit in java. You can convert celsius to fahrenheit using this formula. fh = (1.8*cen) + 32; import java.util.Scanner; public class TempConvertor { public static void main(String args[]) { float cen; double fh; Scanner scanner = new Scanner(System.in); System.out.print("Enter Temperature in Centigrade […]

  • Image
    22 January

    Convert fahrenheit to celsius in java

    In this tutorial, we will see simple java program to convert fahrenheit to celsius in java. You can convert fahrenheit to celsius using this formula. cel = (fh-32) / 1.8; import java.util.Scanner; public class TempConvertor { public static void main(String args[]) { float fh; double cel; Scanner scanner = new Scanner(System.in); System.out.print("Enter Temperature in Fahrenheit […]

  • Image
    20 January

    Java program to delete words from sentence

    In this post, we will see how to delete words from the sentence. You can just use String’s replaceAll method to replace the word with empty String(""). Here is simple java program to delete words from the sentence. import java.util.Scanner; public class StringOperator { public static void main(String args[]) { String str, word; Scanner scan […]

  • Image
    20 January

    Java program to remove vowels from String

    In this tutorial we will see how to remove vowels from String in java. [toc] Using replaceAll() method We will use String’s replaceAll() method to remove vowels from String. import java.util.Scanner; public class StringOperator { public static void main(String args[]) { String str1, str2; Scanner scan = new Scanner(System.in); System.out.print("Enter a String : "); str1 […]

  • Image
    20 January

    Java program to calculate arithmetic mean

    In this tutorial, we will see simple java program to calculate arithmetic mean. Here is simple algorithm to calculate arithmetic mean. Calculate sum of elements in the array Divide it by total number of element in the array. import java.util.Scanner; public class ArithMeanCalc { public static void main(String args[]) { int cnt, i, sum=0, mean; […]

  • Image
    20 January

    Java program to count positive, zero and negative numbers

    In this post, we will see Java program to count positive, zero and negative numbers import java.util.Scanner; public class JavaProgram { public static void main(String args[]) { int contp=0, cntn=0, cntz=0, i; int arr[] = new int[10]; Scanner scan = new Scanner(System.in); System.out.print("Enter 10 Numbers : "); for(i=0; i<10; i++){ arr[i] = scan.nextInt(); } for(i=0; […]

  • Image
    20 January

    Java program to count number of words in sentence

    In this tutorial, we will see a simple java program to count number of words in sentence. import java.util.Scanner; public class StringOperator { public static int countWordsinStr(String str){ int count = 1; for(int i=0; i<=str.length()-1; i++){ if(str.charAt(i) == ' ' && str.charAt(i+1)!=' '){ count++; } } return count; } public static void main(String args[]){ String […]

  • Image
    20 January

    Java program to print Diamond pattern

    In this tutorial, we will see java program to print diamond pattern. import java.util.Scanner; public class DiamondPattPrinter { public static void main(String args[]) { int cnt, c, k, space=1; Scanner scan = new Scanner(System.in); System.out.print("Enter count/number of Rows for Diamond pattern : "); cnt = scan.nextInt(); space = cnt-1; for(k=1; k<=cnt; k++){ for(c=1; c<=space; c++){ […]

  • Image
    19 January

    How to Compare Two Strings in Java

    In this post, we will see how to compare two String in java. As you might know, String implements Comparable interface, you can use compareTo method to compare two String in java. import java.util.Scanner; public class StringComparator { public static void main(String args[]) { String str1, str2; Scanner scan = new Scanner(System.in); System.out.print("Enter First String […]

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.