Posts

Showing posts from 2017

How to Calculate the Future Investment Value of Investment.

Image
Below java program for calculate future investment value. Here calculate s using the formula futureInvestmentValue =investmentAmount x (1 + monthlyInterestRate)^numberOfYears*12.
Output: 




Java code here.
package swain.swain;
import java.util.Scanner;
publicclass CalculateFutureInvestmentValue { publicstaticvoid main(String[] args) {
         Scanner input = new Scanner(System.in);
         System.out.println("Enter investment amount:"); doubleinvestmentAmount = input.nextDouble();          System.out.println("Enter annual interest rate in percentage:"); doublemonthlyInterestRate = input.nextDouble();          System.out.println("Enter number of years:");

Oracle JRE will no longer trust MD5-signed code by default

Image
Beginning with the April 2017 Critical Patch Update, JAR files signed using MD5 will no longer be considered as signed by the Oracle JRE.  Affected MD5-signed JAR files will no longer be considered trusted and as a result will not be able to run by default, such as in the case of Java applets, or Java Web Start applications. This change in the JRE behavior is required because MD5 is no longer considered secure and is widely considered unsuitable for security use.  In fact, the MD5 with RSA algorithm stopped being the default JAR signing option with Java SE 6 released back in 2006.  It is critical that weak hashing algorithms (such as MD5) be deprecated when they are known to be weak so as to maintain the trust in the verification mechanism they provide.   This change affecting MD5-signed JARS will be enabled by default no sooner than with Oracle Java SE 8u131 which will be released with the April 2017 Critical Patch Update, as well as in the corresponding releases of Oracle Java SE 7…

Apache FileUtils Examples.

Image
Apache FileUtils Examples.


General file manipulation utilities.
Facilities are provided in the following areas:
1Writing to a file. 2Reading from a file. 3   Make a directory including parent directories. 4   Copying files and directories. 5Deleting files and directories. 6   Converting to and from a URL. 7Listing files and directories by filter and extension. 8   Comparing file content. 9    File last changed date. 1    Calculating a checksum.
Maven Repository                 <dependency>                                                 <groupId>commons-io</groupId>                                                 <artifactId>commons-io</artifactId>                                                 <version>2.4</version>                                 </dependency>
Examples. package swain.swain;
import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collection;
import org.apache.commons.io.FileUtils; import org.apache.co…

Java Program: Print Pattern with star java example

Image
To find out multiple example of star print pattern.


Output:



Java code.

package swain.swain;

public class PrintPattern {
public static void example1() {
int space = 0;
for (int i = 5; i >= 1; i--) {
// print first part of the row
for (int j = i; j >= 1; j--)
System.out.print("*");

// print space
for (int j = 1; j <= space; j++)
System.out.print(" ");

// print second part of the row
for (int j = i; j >= 1; j--)
System.out.print("*");

// print new lint
System.out.println();
space = space + 2;
}

space = 8;
for (int i = 1; i <= 5; i++) {
// print first part of the row
for (int j = 1; j <= i; j++)
System.out.print("*");

// print space
for (int j = 1; j <= space; j++)
System.out.print(" ");

// print second part of the row
for (int j = 1; j <= i; j++)
System.out.print("*");

// print new lint
System.out.println();
space = space - 2;
}
}

public static void example2() {
int space = 0;
for (int i = 5; i >= 1; i--) {
// print first part of the ro…

Java Program: Basal Metabolic Rate (BMR) Calculator .

Image
Basal metabolic rate (BMR), is the rate of metabolism that occurs when an individual is at rest in a warm environment and is in the post absorptive state, and has not eaten for at least 12 hours.

Find below java program.









package swain.swain;

import java.util.Scanner;

public class BMR {
public static void main(String[] args) {
int age;

double weight, height, BMRw, BMRm;

System.out.println("Enter weight in lbs:");

Scanner kb = new Scanner(System.in);

weight = kb.nextDouble();

System.out.println("Enter height in inches:");

height = kb.nextDouble();

System.out.println("Enter age in years:");

age = kb.nextInt();

BMRw = 655 + (4.3 * weight) + (4.7 * height) - (4.7 * age);

BMRm = 66 + (6.3 * weight) + (12.9 * height) - (6.8 * age);

System.out.println("BMR for woman is: " + BMRw);

System.out.println("BMR for man is: " + BMRm);

System.out.println("A typical Chocolate Bar contains about 230 calories");

System.out.println("No. of Chocolate Bars co…

Java Program : How to find the LOVE percentage calculator between a boy and a girl.

Image
It is a Fun Love calculator  algorithm to find out love percentage. It is only for fun.

You can check FLAMES Game.



Here is Java program.

package swain.swain;
import java.util.ArrayList; import java.util.List;
public class LoveCalculator { private static List<String> getCount(String fname, String sname) { List<String> list = new ArrayList<String>(); String love = "Love"; String name1 = fname; String name2 = sname; for (int i = 0; i < name1.length(); i++) { String temp = name1.charAt(i) + "";
if (list.contains(temp)) { int indexOfElement = list.indexOf(temp); int prevCount = Integer.parseInt(list.get(++indexOfElement).toString()); prevCount++; String newCount = (prevCount) + ""; list.set(indexOfElement, newCount); continue; }
list.add(temp); list.add("1"); }
for (int i = 0; i < name2.length(); i++) { String temp = name2.charAt(i) + "";
if (list.contains(temp)) { int indexOfElement = list.indexOf(temp); int prevCount = Integer.parseInt(…