Skip to main content

Posts

Showing posts from November, 2016

CURRENCY DENOMINATION

PROGRAM: CURRENCY DENOMINATION The Objective is to get currency in sorted manner ie. if user have 5412 Rs then the output might be 2 X 2000 = 4000 1 X 1000 = 1000 4 X 100  = 400 1 X 10   = 10 1 X 2    = 2 __________________ TOTAL:  5412 SYNTAX import java.io.*; class currency_denom { static int a[]={2000,1000,500,100,50,20,10,5,2};static int x=0;     public static void main(String args[])throws IOException     {         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));         System.out.println("Enter Amount");         int n=Integer.parseInt(br.readLine());System.out.println("DENOMINATED CURRENCY:");         int tot=n;         den(n,a[x]);         System.out.println("____________________\nTOTAL: "+tot);     }     public static void den(int n,int cur)     {         if(n>=2000)         {int c=n/2000;             System.out.println(c+" X 2000 = "+(c*2000));             n=n%20

Arranging according to potential.

PROGRAM: Requested by Sir  Ankur Acharya   ARRANGING WORDS IN A STRING ACCORDING TO THEIR POTENTIAL The encryption of alphabets are to be done as follows: A = 1 B = 2 C = 3 . . . Z = 26 The potential of a word is found by adding the encrypted value of the alphabets. Example: KITE Potential = 11 + 9 + 20 + 5 = 45 Accept a sentence which is terminated by either “ . ” , “ ? ” or “ ! ”. Each word of sentence is separated by single space. Decode the words according to their potential and arrange them in ascending order. Output the result in format given below: Example 1 INPUT : THE SKY IS THE LIMIT. POTENTIAL : THE = 33 SKY = 55 IS = 28 THE = 33 LIMIT = 63 OUTPUT : IS THE THE SKY LIMIT Example 2 INPUT : LOOK BEFORE YOU LEAP. POTENTIAL : LOOK = 53 BEFORE = 51 YOU = 61 LEAP = 34 OUTPUT : LEAP BEFORE LOOK YOU SYNTAX import java.io.*; class Potential {     public static void main(String args[])throws IOException     {         BufferedReader br=new BufferedReader(new Inp