Epic Systems Interview Question
Developer Program EngineersCountry: United States
package interviewQuestions;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class subStringexm {
public static void operation(float hits, float chances,float games_left){
float hits1,chances1;
hits1=hits;
chances1=chances;
float rate1=(hits1)/chances1;
System.out.println(+hits+" "+chances+""+games_left);
System.out.println(+hits1+" "+chances1);
System.out.println("Rate of hitting"+rate1);
float futurehits,future_chances;
float rate=(float) 0.45;
future_chances=games_left;
futurehits=future_chances * rate;
// rate= (futurehits)/future_chances;
System.out.println("Future hits "+futurehits);
//System.out.println("Future rate"+rate);
}
public static void main(String[] args) {
try{
BufferedReader number_hits= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Number of hits");
float hits=(Float.parseFloat(number_hits.readLine()));
BufferedReader number_chances= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter no of chances");
float chances= Float.parseFloat(number_chances.readLine());
BufferedReader number_of_games_left= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter no of games left");
float games_left= Float.parseFloat(number_of_games_left.readLine());
operation( hits, chances,games_left);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
public static void main(String[] args) throws Exception, IOException {
// TODO Auto-generated method stub
int num_of_hits, num_of_chances, num_of_remaining_games, number_of_played_games;
int num_of_future_hits, num_of_future_chances;
System.out.println("Enter the number of hits");
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
num_of_hits = Integer.parseInt(buf.readLine());
System.out.println("Enter the number of chances");
BufferedReader buf2 = new BufferedReader(new InputStreamReader(System.in));
num_of_chances = Integer.parseInt(buf2.readLine());
System.out.println("Enter the number of remaining games");
BufferedReader buf3 = new BufferedReader(new InputStreamReader(System.in));
num_of_remaining_games = Integer.parseInt(buf3.readLine());
number_of_played_games = 162 - num_of_remaining_games;
/*
* (num_of_hits + num_of_future_hits)/(num_of_chances + num_of_future_chances) = 0.45
*
* number_of_played_games = num_of_chances
* num_of_remaining_games = ??? num_of_future_chances
*
*
*/
num_of_future_chances = Math.round((num_of_remaining_games * num_of_chances)/number_of_played_games);
num_of_future_hits = (int) Math.round (((num_of_chances + num_of_future_chances) * 0.45) - num_of_hits);
System.out.println("The predicted future hits to maintain hit rate of 0.45 is: "+num_of_future_hits);
}
public static void main(String[] args) throws Exception, IOException {
// TODO Auto-generated method stub
int num_of_hits, num_of_chances, num_of_remaining_games, number_of_played_games;
int num_of_future_hits, num_of_future_chances;
System.out.println("Enter the number of hits");
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
num_of_hits = Integer.parseInt(buf.readLine());
System.out.println("Enter the number of chances");
BufferedReader buf2 = new BufferedReader(new InputStreamReader(System.in));
num_of_chances = Integer.parseInt(buf2.readLine());
System.out.println("Enter the number of remaining games");
BufferedReader buf3 = new BufferedReader(new InputStreamReader(System.in));
num_of_remaining_games = Integer.parseInt(buf3.readLine());
number_of_played_games = 162 - num_of_remaining_games;
/*
* (num_of_hits + num_of_future_hits)/(num_of_chances + num_of_future_chances) = 0.45
*
* number_of_played_games = num_of_chances
* num_of_remaining_games = ??? num_of_future_chances
*
*
*/
num_of_future_chances = Math.round((num_of_remaining_games * num_of_chances)/number_of_played_games);
num_of_future_hits = (int) Math.round (((num_of_chances + num_of_future_chances) * 0.45) - num_of_hits);
System.out.println("The predicted future hits to maintain hit rate of 0.45 is: "+num_of_future_hits);
}
Aren't u all forgetting number of chances per game , 4.5??
so, num_of_future_chances=162*4.5-num_of_chances_he_had
so futurehits=0.45*num_of_future_chances
import java.util.Scanner;
public class HitRate{
public static void main(String [] args){
Scanner in = new Scanner (System.in);
System.out.println("Enter number of hits");
int numOfHits=in.nextInt();
System.out.println("Enter the number of chances");
int numOfChances=in.nextInt();
System.out.println("Enter the remaining number of games");
int numOfGamesRemain = in.nextInt();
int numOfFutHits=0;
System.out.println("current hit rate: "+(double)Math.round((numOfHits*1000/numOfChances))/1000);
System.out.println("No. of future hits required: "+Math.ceil((0.45*162*4.5)-numOfHits));
}
}
- Srikanth dukuntla June 30, 2015