Soluții

Java Program to Calculate Compound Interest

Compound interest is calculated using the following formula:

P (1 + R/n) (nt) - P

Here P is principal amount.
R is the annual interest rate.
t is the time the money is invested or borrowed for.
n is the number of times that interest is compounded per unit t, for example if interest is compounded monthly and t is in years then the value of n would be 12. If interest is compounded quarterly and t is in years then the value of n would be 4.

Before writing the java program let’s take an example to calculate the compound interest. Let’s say an amount of $2,000 is deposited into a bank account as a fixed deposit at an annual interest rate of 8%, compounded monthly, the compound interest after 5 years would be:

P = 2000.
R = 8/100 = 0.08 (decimal).
n = 12.
t = 5.

Let’s put these values in the formula.

Compound Interest = 2000 (1 + 0.08 / 12) (12 * 5) – 2000 = $979.69

So, the compound interest after 5 years is $979.69.

[mai mult...]

Java Program to check Vowel or Consonant using Switch Case

The alphabets A, E, I, O and U (smallcase and uppercase) are known as Vowels and rest of the alphabets are known as consonants. Here we will write a java program that checks whether the input character is vowel or Consonant using switch case in java.

In this program we are not using break statement with cases intentionally, so that if user enters any vowel, the program continues to execute all the subsequent cases until Case 'U' is reached and thats where we are setting up the value of a boolean variable to true. This way we can identify that the alphabet entered by user is vowel or not.

[mai mult...]

Java Program to check Leap Year

Before we see the program, lets see how to determine whether a year is a leap year mathematically:
To determine whether a year is a leap year, follow these steps:
1. If the year is evenly divisible by 4, go to step 2. Otherwise, go to step 5.
2. If the year is evenly divisible by 100, go to step 3. Otherwise, go to step 4.
3. If the year is evenly divisible by 400, go to step 4. Otherwise, go to step 5.
4. The year is a leap year (it has 366 days).
5. The year is not a leap year (it has 365 days).

[mai mult...]

How to Read and Print an Integer value in Java

In below program, the syntax and procedures to take the integer as input from the user is shown in Java language. Steps:

  1. The user enters an integer value when asked.
  2. This value is taken from the user with the help of nextInt() method of Scanner Class. The nextInt() method, in Java, reads the next integer value from the console into the specified variable. Syntax:
  3. variableOfIntType = ScannerObject.nextInt();
  4. where variableOfIntType is the variable in which the input value is to be stored. And ScannerObject is the beforehand created object of the Scanner class.
    1. This entered value is now stored in the variableOfIntType.
    2. Now to print this value, System.out.println() or System.out.print() method is used. The System.out.println() method, in Java, prints the value passed as the parameter to it, on the console screen and the changes the cursor to the next line on the console. Whereas System.out.print() method, in Java, prints the value passed as the parameter to it, on the console screen and the cursor remains on the next character of the last printed character on the console.
[mai mult...]

How to add Yoga Mode to your Samsung Galaxy Watch

The Samsung Galaxy Watch is one of the popular smartwatches with Yoga mode. It helps you track vital metrics while doing yoga. While the mode isn’t directly preloaded on the watch, you can add it to your workout modes screen with a few simple taps.

When you add the yoga mode to your Galaxy Watch and start it, you can see essential stats like average heart rate, maximum heart rate, and more on the screen. Before starting the yoga workout mode, you can also set a target for calories or time duration.

After starting, you will see the time duration on the watch screen with calories burnt and heart rate data. Scrolling down will also see a detailed heart rate data chart with average and maximum heart rates during the session.

[mai mult...]