Jump to content

java experts


pawan kalyan

Recommended Posts

  • Replies 33
  • Created
  • Last Reply

Top Posters In This Topic

  • ICANWIN

    10

  • Prabhas_Fan

    9

  • BaabuBangaram

    4

  • fake_Bezawada

    3

Popular Days

Top Posters In This Topic

Baaga Khaliga unna.. Njoy+-

 

package com.afdb;

 

import java.util.HashMap;

import java.util.Map;

 

public class AtmDenomination {

 

 

public Map<Integer,Integer> getDenominations(int amount){

HashMap<Integer,Integer> denom= new HashMap<Integer,Integer>();

if(amount%100  >0 ){

return  denom;

}

int twothousand=0,fivehundred = 0,hundred =0;

while(amount > 0){

if(amount-2000 >=0){

twothousand++;

amount -=2000;

}else if(amount-500 >=0){

fivehundred++;

amount -=500;

}else if(amount-100 >=0){

hundred++;

amount -=100;

}

 

}

denom.put(2000, twothousand);

denom.put(500, fivehundred);

denom.put(100,hundred);

return denom;

}

 

public static void main(String[] args) {

// TODO Auto-generated method stub

AtmDenomination atm = new AtmDenomination();

Map<Integer,Integer> denom = atm.getDenominations(5600);

if(!denom.isEmpty()){

for(Map.Entry<Integer, Integer> entry:denom.entrySet()){

System.out.println("Number of "+entry.getKey()+" is "+entry.getValue());

}

}else{

System.out.println("Enter multiples of 100");

}

 

}

 

}

Link to comment
Share on other sites

5 hours ago, ICANWIN said:

Btech chadivina andariki logic unte code rayadam compile chesi excute cheyadam vastundi antav ..oka sari malla alochinchi cheppu +-

brahmi%20laugh.gif

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...