Amazon Interview Question
Quality Assurance EngineersTeam: Kindle
Country: India
Interview Type: Written Test
var obtainedMarks = 20;
var totalMarks = 40;
var gradeCalculation = 100*(obtainedMarks/totalMarks);
var result = string.Empty;
if (gradeCalculation >= 0 && gradeCalculation <= 40)
{
result = "D Grade";
}
else if (gradeCalculation >= 41 && gradeCalculation <= 60)
{
result = "C Grade";
}
else if (gradeCalculation >= 61 && gradeCalculation <= 80)
{
result = "B Grade";
}
else if (gradeCalculation >= 81 && gradeCalculation <= 100)
{
result = "A Grade";
}
else
{
result = string.Empty;
}
const int obtainedMarks = 20;
const int totalMarks = 40;
var gradeCalculation = 100*(obtainedMarks/totalMarks);
var result = string.Empty;
if (gradeCalculation >= 0 && gradeCalculation <= 40)
{
result = "D Grade";
}
else if (gradeCalculation >= 41 && gradeCalculation <= 60)
{
result = "C Grade";
}
else if (gradeCalculation >= 61 && gradeCalculation <= 80)
{
result = "B Grade";
}
else if (gradeCalculation >= 81 && gradeCalculation <= 100)
{
result = "A Grade";
}
else
{
result = string.Empty;
}
Ask what type of values can be passed to Grade function.
- undefined September 21, 2016If its in string format, then we need to Parse the values to Int.
If its a string format, then it can be null or empty or can have spaces in between.
Test data to test function Grade(ObtainedMarks, TotalMarks):
1. Boundary conditions.
Test each individual grades for their boundary conditions.
i.e MarksObtained = 0, 40, 41, 60, 61, 80, 81 and 100, assuming that TotalMarks = 100.
If total marks != 100, then change the values to test those Percentages.
2. Negative conditions.
MarksObtained = -10, total marks = 0.
This will cause divide by Zero Exception.
3. Invalid conditions:
Marks obtained = 110. Total Marks = 100.
Passing alphanumeric or special characters.
4. All possible combination of numbers of a number scale. i.e negative values, zero and positive values for both the parameters, MarksObtained and TotalMarks.