import java.util.Scanner;
public class basic{
public static void main(String[] args){
System.out.println("Enter your limit : ");
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int f = 1;
for(int i=1;i<=n;i++){
f=f*i;
}
System.out.println(f);
}
}
import java.util.Scanner;
public class basic{
public static void main(String[] args){
System.out.println("Enter your limit : ");
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int sum = 0,a;
for(int i=1;i<=n;i++){
System.out.println("Enter your value "+i+" :");
a = in.nextInt();
sum+=a;
}
System.out.println(sum/n);
}
}
import java.util.Scanner;
public class basic{
public static void main(String[] args){
System.out.println("Enter your limit : ");
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int a = -1,b=1,c;
for(int i=1;i<=n;i++){
c=a+b;
System.out.println(c);
a=b;
b=c;
}
}
}
import java.util.Scanner;
public class basic{
public static void main(String[] args){
System.out.println("Enter your value : ");
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int reverse = 0, rem;
while(n!=0){
rem=n%10;
reverse = (reverse*10)+rem;
n=n/10;
}
System.out.println(reverse);
}
}
import java.util.Scanner;
public class basic{
public static void main(String[] args){
System.out.println("Enter your value : ");
Scanner in = new Scanner(System.in);
int number = in.nextInt();
int temp = number;
int d1,d2,d3;
d1 = temp%10;
temp = temp/10;
d2 = temp%10;
temp = temp/10;
d3 = temp%10;
temp=temp/10;
int result = (d1*d1*d1)+(d2*d2*d2)+(d3*d3*d3);
if(number == result){
System.out.println(number+" is armstrong number");
}else{
System.out.println(number+" is not armstrong number");
}
}
}
public class basic{
public static void main(String[] args){
int d1,d2,d3,temp,result;
for(int i=100; i<+999; i++){
temp = i;
d3 = temp%10;
temp = temp/10;
d2 = temp%10;
temp = temp/10;
d1 = temp%10;
result = (d1*d1*d1)+(d2*d2*d2)+(d3*d3*d3);
if(i == result){
System.out.println(i+" is armstrong number");
}
}
}
}
import java.util.Scanner;
public class basic{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.println("Enter your number : ");
int n = in.nextInt();
for (int i = 1; i <= n; i++){
if(n%i==0){
System.out.println(i);
}
}
}
}
import java.util.Scanner;
public class basic{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.println("Enter your number : ");
int n = in.nextInt();
int f = 0;
for (int i = 1; i <= n; i++){
if(n%i==0){
f++;
}
}
if(f==2){
System.out.println(n +" is prime number");
}else{
System.out.println(n +" is not prime number");
}
}
}
import java.util.Scanner;
public class HelloWorld{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.println("Enter your number : ");
int n = in.nextInt();//6
int sum = 0;
for (int i = 1; i < n; i++){
if(n%i==0){
sum+=i;
System.out.println(sum);
}
}
if(sum==n){
System.out.println(n +" is perfect number");
}else{
System.out.println(n +" is not perfect number");
}
}
}
import java.util.Scanner;
public class basic{
public static void main(String[] args){
int num,orgnum,rem,factorial,sum=0;
Scanner in = new Scanner(System.in);
System.out.println("Enter your number : ");
num = in.nextInt();
orgnum = num;
while(num>0){
rem=num%10;
factorial = 1;
for(int i = 1; i<=rem; i++){
factorial*=i;
}
sum+=factorial;
num=num/10;
}
if(sum==orgnum){
System.out.println(orgnum + " is a strong number");
}else{
System.out.println(orgnum + " is not a strong number");
}
}
}
Input the investment amount: 1000, Input the rate of interest: 10, Input number of years: 5
Years | FutureValue |
---|---|
1 | 1104.71 |
import java.lang.Math;
public class compounded {
public static void main(String[] args) {
int investmentAmount = 1000;
double monthlyInterestRate = 0.00833;
int years = 1;
double result = investmentAmount * Math.pow((1 + monthlyInterestRate), years * 12);
System.out.println(result);
}
}