java programs
- 22 January
Java program to subtract two matrices
In this post, we will see how to subtract two matrices in java.I am giving example for 33 matrix. You can extend it to nn matrices. [crayon-673f9ad1c7f12293375863/] Output: Enter Matrix 1 Elements : 11 22 33 44 55 66 77 88 99 Enter Matrix 2 Elements : 10 20 30 40 50 60 70 80 […]
- 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; [crayon-673f9ad1ca121370509906/] Output: Enter Temperature in Centigrade : 30 Equivalent Temperature in Fahrenheit = 86.0
- 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; [crayon-673f9ad1ca20e496386248/] Output: Enter Temperature in Fahrenheit : 79 Equivalent Temperature in Celsius : 26.11111111111111
- 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. [crayon-673f9ad1ca2cb443796809/] Output: Enter a String : Java2Blog is a technical blog. Enter a Word you want to […]
- 20 January
Java program to remove vowels from String
In this tutorial we will see how to remove vowels from String in java. Using replaceAll() method We will use String’s replaceAll() method to remove vowels from String. [crayon-673f9ad1ca391718822952/] Output: Enter a String : Java2Blog All Vowels Removed Successfully..!! New String is : Jv2Blg Explaination Take input String from Scanner str1 Call replaceAll() method on […]
- 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. [crayon-673f9ad1ca488696435553/] Output: Please enter count of numbers you want to Enter ? 5 Enter 5 Numbers : […]
- 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 [crayon-673f9ad1ca546321725815/] Output: Enter 10 Numbers : 10 0 45 -10 67 0 76 -33 64 -92 5 Positive Numbers 3 Negative Numbers 2 Zero That’s all about Java program to count positive, zero and negative numbers
- 20 January
Program to find frequency of characters in a string in java
In this tutorial, we will see simple program to find frequency of characters in a string in java. There are multiple ways to solve this proble. Let’s see one by one. Using counter array Here is the algorithm for the same. Initialize counter array of 256 length Iterate over String and increase count by 1 […]
- 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. [crayon-673f9ad1cafc7607583340/] Output: Enter a Sentence : Java2Blog is a technical blog. Total number of words are 5 That’s all about Java program to count number of words in sentence.