Posts

Showing posts with the label scanner

mathajax

Java program Factorial Number

A result of series of multiplication from 1 to factorial F is called factorial number F Factorial Number - Example for example, a factorial number denoted by 5! (postfix exclamation symbol with digits) find equivalent decimal value for given a factorial number 5! 5! = 1 x 2 x 3 x 4 x 5 5! = 120 Factorial Number - Pseudocode Read a positive integer F set sf = 1 For n= 2 to F sf = sf * n End for print sf Factorial number - Java code The Java program finds factorial value for a number . The program reads a positive integer from user while running and returns factorial value as result of the it. import java.io.IOException; import java.util.Scanner; public class Factorial { public static void main(String[] args) throws IOException { ...

Java program Biggest number among N Integers

In order to f ind biggest number from unordered (not sorted) set of N numbers , a sequential search mechanism used, in which search starts from zero index to N-1 index. A Biggest number from array numbers - Pseudocode Read a integer N initialize memory array of N element Read integers and store into an array set biggest = 0; for n=0 to N check array[n] > biggest , set biggest = array[n] end for print biggest A Biggest number from array of numbers - Java program The Java program read N integers from user via keyboard and stored on an array. It has a for-loop to start sequential search to find a biggest number from this array of numbers . import java.io.IOException; import java.util.Scanner; public class BiggestAmongN { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); System.out.println( "Enter Number of Eleme...