Epic Systems Interview Question for Software Engineer / Developers






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

public class change {
	private static final double[] denominations = {10.0, 5.0, 1.0, .5, .25,
		.1, .05, .01 };
	public static void main(String[] args) {
		double sum=15.38;
		for(double d:denominations){
			int num=(int)Math.floor(sum/d);
			if(num!=0){
			System.out.println(num+"*"+d+";");}
			sum-=d*num;
		}
	}

}

- disun March 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

total_change=(total_paid-need_payment)*100;

change_10_dollar=total_change/1000;
total_change%=1000;
change_5_dollar=total_change/500;
total_change%=500;
change_1_dollar=total_change/100;
total_change%=100;
change_25_cent=total_change/25;
total_change%=25;
change_10_cent=total_change/10;
total_change%=10;
change_5_cent=total_change/5;
total_change%=5;
change_1_cent=total_change/1;

- Shane.Y.Fang December 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

not good enough

- helen January 12, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Elegant Answer!

- logNguy December 08, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I remember this is a classic greedy algorithm homework...

- hobocs December 08, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

it is. There is an example in my algorithm book

- matt.oy1985 June 03, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is this the best answer?

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

Nice Answer!

- Anonymous January 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

double deno[]= {10, 5, 1, 0.25, 0.10, 0.5, 0.1};
		Scanner reader = new Scanner(System.in);
		float cost = reader.nextFloat();
		float cash = reader.nextFloat();
		float change = cash-cost;
		System.out.println(change);
		for(int i=0;i<deno.length;i++)
		{
			float quo = (float) ((float) change/deno[i]);
			float rem = (float) ((float) change%deno[i]);
			
			if (quo>=1)
			{
				float num = (float) ((float) (change-rem)/deno[i]);
				System.out.printf("Number of "+deno[i]+"s: "+num+"\n");
				change = (float) (change-(num*deno[i]));
			}
			
		}
		
	}
}

- Anonops February 11, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Good Logic.. But needs a slight Modification ion denominations

double deno[]= {10, 5, 1, 0.25, 0.10, 0.05, 0.01};
		//Scanner reader = new Scanner(System.in);
		float cost = 67.9500f;
		float cash = 100.00f;
		float change = cash-cost;
		System.out.println(change);
		for(int i=0;i<deno.length;i++)
		{
			float quo = (float) ((float) change/deno[i]);
			float rem = (float) ((float) change%deno[i]);

			if (quo>=1)
			{
				float num = (float) ((float) (change-rem)/deno[i]);
				System.out.printf("Number of "+deno[i]+"s: "+num+"\n");
				change = (float) (change-(num*deno[i]));
			}

		}

- Anonymous March 31, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

/* Function declarations */
void giveTheChange(int dollar, int cents, vector<int> &inDollar, vector<int> &inCent);
void process(int &sum,vector<int> &denom,bool dollar);

/* Function definitions */
void giveTheChange(int dollar, int cents, vector<int> &inDollar, vector<int> &inCent){

/* Find minmum number of dollars needed to give the change */
int sum=dollar;
int centsLeft;
int sumCent=cents;

process(sum,inDollar,true);
if(sum!=0){

centsLeft=sum*100;
sumCent+=centsLeft;

}
process(sumCent,inCent,false);

}


void process(int &sum,vector<int> &denom,bool dollar){
while(sum!=0 && denom.size()!=0)
{
if(denom.back()<= sum )
{
sum-=denom.back();
if(dollar)
cout<<"$"<<denom.back()<<" ";
else
cout<<"##"<<denom.back()<<" ";
//inDollar.pop_back();
}
else
{
denom.pop_back();
}
}
}

int main()
{
char key;
int dollarArray[]={4};
int centArray[]={25,10};
int dollar,cents;
vector <int> inDollar(dollarArray,dollarArray+sizeof(dollarArray)/sizeof(int));
sort(inDollar.begin(), inDollar.end());
vector<int> inCent(centArray, centArray+sizeof(centArray)/sizeof(int));
sort(inCent.begin(), inCent.end());
cout<<"Enter the amount that you wanna make change "<<endl;
cin>>dollar ; cout<<" "; cin >>cents;
cout<<endl;
giveTheChange(dollar, cents, inDollar, inCent);

cin>>key;
return 0;
}

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

import java.util.Scanner;


public class Main {

public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Enter the cost of the item: ");
double cost = in.nextFloat();
System.out.print("Enter the cash given by the customer: ");
double cashGiven = in.nextFloat();
double coins[] ={10,5, 1, 0.25 , 0.05, 0.01 };
double change = cashGiven - cost;
if(change ==0){
System.out.println("No change will be given back");

}
else if(change <0){
System.out.println("Cash given is lesser than the cost");
}
else{
for(int i=0;i<coins.length;i++){
int qou = (int)(change/coins[i]);
if(qou >=1){
System.out.println("No of "+ coins[i] + ": "+qou);
change = (double)(change-(coins[i]*qou));
}
}
}
}
}

- Anonymous April 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

<pre lang="" line="1" title="CodeMonkey92099" class="run-this">import java.util.Scanner;


public class Main {

public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Enter the cost of the item: ");
double cost = in.nextFloat();
System.out.print("Enter the cash given by the customer: ");
double cashGiven = in.nextFloat();
double coins[] ={10,5, 1, 0.25 , 0.05, 0.01 };
double change = cashGiven - cost;
if(change ==0){
System.out.println("No change will be given back");

}
else if(change <0){
System.out.println("Cash given is lesser than the cost");
}
else{
for(int i=0;i<coins.length;i++){
int qou = (int)(change/coins[i]);
if(qou >=1){
System.out.println("No of "+ coins[i] + ": "+qou);
change = (double)(change-(coins[i]*qou));
}
}
}
}
}

</pre><pre title="CodeMonkey92099" input="yes">
</pre>

- Anonymous April 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int main(){
double total_paid,need_payment,total_change,change_10_dollar, change_5_dollar, change_1_dollar, change_25_cent, change_10_cent, change_1_cent;
cout<<"enter the amount need to be paid: ";
cin>>need_payment;
cout<<"enter the amount paid: ";
cin>>total_paid;
total_change=(total_paid-need_payment)*100;
cout<<"Total money need to be returned is: " << total_change <<" cents." << endl << endl;
cout <<"Denominations could be:::"<<endl;

change_10_dollar = floor(total_change/1000);
cout<<"10 dollar bill is: "<<change_10_dollar<<endl;
total_change -= change_10_dollar*1000;

change_5_dollar = floor(total_change/500);
cout<<"5 dollar bill is: "<<change_5_dollar<<endl;
total_change -= change_5_dollar*500;

change_1_dollar = floor(total_change/100);
cout<<"1 dollar bill is: "<<change_1_dollar<<endl;
total_change -= change_1_dollar*100;

change_25_cent = floor(total_change/25);
cout<<"25 cents coins is: "<<change_25_cent<<endl;
total_change -= change_25_cent*25;

change_10_cent = floor(total_change/10);
cout<<"10 cent coin is: "<<change_10_cent<<endl;
total_change -= change_10_cent*10;

change_1_cent = floor(total_change/1);
cout<<"1 cent coin is: "<<change_1_cent<<endl;
total_change -= change_1_cent*1;

return 0;
}

- Shekhar Agrawal June 30, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

money=[10,5,1,.25,.10,.05,.01]

cost = 20.4
cash = 100

change = cash - cost


print (change)

for x in money :
quo = change / x
rem = change % x
if quo >=1:
num = int(change/x)
print ( "number of %s's equals %d" %(x,num))
change= change - (num * x)

- python_coder March 30, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class Denominations {

	public static void main(String[] args) {
		// We assume we have following denominations
		// $10, $5, $1, 25 cents, 10 cents, 5 cents and 1 cent.
		
		double denom[] = new double[] { 10, 5, 1, 0.25, 0.1, 0.05, 0.01 };

		double input = 27.8;

		for (int i = 0; i < denom.length; i++) {
			int x = (int) Math.floor(input / denom[i]);
			if (x != 0) {
				System.out.println(x + " * " + denom[i]);
			}
			input = input - (x * denom[i]);
		}

	}
}

- Solution September 17, 2014 | 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