Epic Systems Interview Question for System Administrators






Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Calculate the Payment-Cost, say X
2. Start dividing X with largest denomination and pay the remainder number of denominations. X = X - (Remainder no. * denomination)
3. Repeat step 2 until X == 0

Say cost is 75 cents
Payment done is 10$
X = 9.25
X % 10 = 0 ( 0 * 10)
X % 5 = 1 (1 * 5) X = 9.25 - 5 = 4.25
X % 1 = 4 (4 * 1) X = 4.25 - 4.00 = .25
X % 25 = 1 (1 * .25) X = .25 - .25 = 0
X == 0

- cuppanomics May 11, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

No need for checking 10$. Obviously since 10$ is the maximum denomination accepted and assuming the customer purchases something...the cashier cannot give 10$ back.

- din May 12, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class Denomination {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		double amountPaid;
		double itemCost, amountReturned;
		int index = 0;
		double denominations[] = {10, 5, 1, .25, .1, .05, .01};
		itemCost = .5;
		amountPaid = 5;
		amountReturned = amountPaid - itemCost;
		System.out.println("Return a total of $" + amountReturned + ".");
		while(amountReturned > 0) {
			int num_denominations = (int) (amountReturned/denominations[index]);
			amountReturned = amountReturned - (num_denominations*denominations[index]);
			System.out.println("Number of $" + denominations[index] + " to be returned: " + num_denominations);
			index++;
		}
	}

}

- Hello June 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This code may appear correct to the eye, but the while loop, under some conditions, turn into an infinite loop causing an out of bounds exception. When working with decimals you really need to be cautious about precision. If you don't believe me, try running this program using .52 as the cost instead of .5.

- anonymous July 08, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

use cents as unit then all variables and array define as int.

- Anonymous September 20, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

It causes ArrayIndexOutOfBoundsException if we use 0.52

- gp November 15, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Good work. Only correction is -
DecimalFormat twoDForm = new DecimalFormat("#.##");
amountReturned =
Double.valueOf(twoDForm.format(amountReturned - (num_denominations*denominations[index])));

- Anonymous April 08, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I added index<7 condition to the while loop to prevent it

- xx April 11, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Using greedy algorithm can solve this problem easily.

- chinasmart August 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

//take input cost as float cost_f
//multiply by 100 to and cast to int
cost_i = (int) (cost_f*100) //100 since 1c (1/100 of $1) is least
//repeatedly divide by domination *100 to get respective values
tens = cost_i/(10*100); modulo_ten = cost_i%(10*100);
fives = modulo_ten/(5*100); modulo_five = modulo_ten%500;
//and so on.. till one_cents

- C coder September 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Dynamic programming solution appears to be the optimal one.

- xyz February 28, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

/*
At a geeks goodies store.. every thing is either one dollar or less. and they accept only 10 dollars or less than 10 as denominations.So make a function that takes in the cost and payment as input and that out puts the change.
The denominations are namely 1c,5c,10c,25c,$1,$5,$10.
*/
#include<iostream>
using namespace std;

float coins[]={5,2,1,0.25,0.10,0.05,0.01};
#define TOTALCOINS 7

void coin_change(float cost,float payment)
{
	if (payment<0.01 || cost<0.01){cout<<"Ivalid Input";}
	else if (payment>10){cout<<"We only accept denominations upto 10 dollars \n";}
	else if (cost>payment){cout<<"Payment is less than the cost. Please give $"<<cost<<endl;}
	else if (cost==payment){cout<<"Payment complete. Thank you for visit.\n";}
	else
	{
		int num_of_coins[TOTALCOINS]={0};
		float to_return=payment-cost;
		int index=0,c=0;
		while (to_return>0 && index<TOTALCOINS)
		{
			c=(int)(to_return/coins[index]);
			num_of_coins[index]=c;
			to_return=to_return-(c*coins[index]);
			index++;
		}
		for(int i=0;i<TOTALCOINS;i++)
		{
			cout<<"Number of $"<<coins[i]<<" coins= "<<num_of_coins[i]<<endl;
		}
	}
}

int main()
{
	float cost,payment;
	cout <<"Enter the cost\n";
	cin>>cost;
	cout<<"Enter the payment\n";
	cin>>payment;
	coin_change(cost,payment);
	
}

- priyanshu October 27, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Python working code

"""
12:50
@Python 2.7
At a geeks goodies store.. every thing is either one dollar or less. and they accept only 10 dollars or less than 10 as denominations.So make a function that takes in the cost and payment as input and that out puts the change. 
The denominations are namely 1c,5c,10c,25c,$1,$5,$10

- rohith on May 11, 2010 Report Duplicate | Flag 
"""

class CoinChange(object):
  def __init__(self, payment, cost):
    if payment is None or cost is None:
      print 'invalid inputs'
      raise SystemExit
      
    self._payment = payment * 100
    self._cost = cost * 100
    self._coins = [1000, 500, 100, 25, 10, 5, 1]
    
  def getChange(self):
    total = self._payment - self._cost
    pos = 0
    while total > 0:
      # print total, '/', self._coins[pos]
      tmp = int(total // self._coins[pos])
      # print 'tmp = ', tmp
      total = total - tmp * self._coins[pos]
      print str(tmp) + ' X $' + str(self._coins[pos] / 100.0)
      pos += 1
      
if __name__ == '__main__':
  cc = CoinChange(10, 0.15)
  cc.getChange()

- tosay.net March 20, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More