From 6a1b4fc1306e564cbe3f7aa77e66a7e1159dee57 Mon Sep 17 00:00:00 2001 From: iamshashank Date: Thu, 29 Oct 2020 17:20:05 +0530 Subject: [PATCH 1/2] Added Armstrong.java to java --- java/Armstrong.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 java/Armstrong.java diff --git a/java/Armstrong.java b/java/Armstrong.java new file mode 100644 index 0000000..ca8f9d8 --- /dev/null +++ b/java/Armstrong.java @@ -0,0 +1,29 @@ +//Program to check whether a number is an armstrong number or not. +//A positive integer is called an Armstrong number of order n if the sum of cubes of each digits is equal to the number itself. + +import java.util.Scanner; + +public class Armstrong { + + public static void main(String[] args) + { + System.out.println("Enter any number: "); + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int m, rem, res = 0; + + m = n; + + while(m!= 0) + { + rem = m % 10; + res+= Math.pow(rem, 3); + m /= 10; + } + + if(res == n) + System.out.println(n + " is an Armstrong number."); + else + System.out.println(n + " is not an Armstrong number."); + } +} \ No newline at end of file From 8d90c8d9c957d870ee91b2f138ef4a1623202152 Mon Sep 17 00:00:00 2001 From: iamshashank Date: Thu, 29 Oct 2020 17:23:03 +0530 Subject: [PATCH 2/2] Added Median.java to java folder --- java/Median.java | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 java/Median.java diff --git a/java/Median.java b/java/Median.java new file mode 100644 index 0000000..9c2117c --- /dev/null +++ b/java/Median.java @@ -0,0 +1,33 @@ +import java.util.*; +import java.io.*; +import java.lang.*; +class Median +{ + public static void main(String args[]) + { + Scanner sc=new Scanner(System.in); + System.out.println("Enter the number of elements in the array"); + int n=sc.nextInt(); + double[] input=new double[n]; + System.out.println("Enter the elements of the array(" +n+ "): "); + for(int i=0;i