Infosys FA1 Mock Assessment

Wingspan Proctor v3.0.6 Duration: 150 Mins Max Marks: 20

Instructions & Guidelines to Candidates

View README.md

Exam Rules

  1. Follow the class diagram strictly. Read the problem statement, examples and the other details provided carefully and implement the solution.
  2. Code submitted with compilation errors may not get evaluated.
  3. DO NOT add any new method apart from the one given in the file where you write the solution.
  4. DO NOT alter the method name or the argument list of the method that is provided to you.
  5. DO NOT write codes that result in infinite loops / infinite recursive calls, because it just won't work!
  6. The test cases provided are a subset of test cases that will be used to test your code.
Mark Reduction Warnings:
  • Removal / modification of package statements
  • Infinite loops / infinite recursive calls
  • Class diagram violation
  • Improper constructor prototype or definition
Candidate Instructions Screen
Original Screen Capture - Wingspan Proctor Instructions

Question 1: Programming Fundamentals — Token Validation

5 Marks Raw .md

Problem Description

Mr. Charles is developing a pharmaceuticals system to generate a verification token based on the input string. Write code in the given Java method to implement the requirement.

Input & Output Format

  • Input: A String containing at most one $ character.
  • Output: Returns a String.
  • Constraints: input string length >= 1

Validation Rules

  • Check whether the input string contains two parts separated by a $ in the format <part1>$<part2>.
  • If format is valid (both parts non-empty):
    • part1 must contain only lowercase alphabets (a-z).
    • part2 must contain only digits (0-9).
  • Return:
    • If both conditions satisfied: return "<part1>_valid"
    • Otherwise: return "<part1>_invalid"
  • If the input string does not follow the required format (e.g. missing $, multiple $, empty parts): return "invalid".

Sample Test Cases

Example Input Expected Output Explanation
1 "colpol$01" "colpol_valid" Valid format, part1 is lowercase letters, part2 is digits
2 "123e$456" "123e_invalid" Valid format, but part1 contains digits
3 "dolo650" "invalid" Missing '$' delimiter
4 "crocin$50$" "invalid" Contains multiple '$' symbols
Question 1 Screen Capture
Original Screen Capture - Question 1
✔ Java Solution Code — pfusingjava1.Solution
package pfusingjava1;

public class Solution {

    public static String tokenValidation(String input) {
        if (input == null || input.isEmpty()) {
            return "invalid";
        }

        int firstDollar = input.indexOf('$');
        int lastDollar = input.lastIndexOf('$');

        // Must have exactly one '$'
        if (firstDollar == -1 || firstDollar != lastDollar) {
            return "invalid";
        }

        String part1 = input.substring(0, firstDollar);
        String part2 = input.substring(firstDollar + 1);

        // Both parts must be non-empty
        if (part1.isEmpty() || part2.isEmpty()) {
            return "invalid";
        }

        boolean part1Valid = part1.matches("^[a-z]+$");
        boolean part2Valid = part2.matches("^[0-9]+$");

        if (part1Valid && part2Valid) {
            return part1 + "_valid";
        } else {
            return part1 + "_invalid";
        }
    }
}

Question 2: Programming Fundamentals — Inventory Batch Audit

5 Marks Raw .md

Problem Description

The "CERT-AO" organization audits inventory batches. Write code in the given Java method to implement the requirement.

Input & Output Format

  • Input:
    • 1D integer array named actualArr representing actual quantities.
    • 1D integer array named thresholdArr representing target threshold values.
  • Output: Returns a 1D String array named outArr.
  • Constraints: 0 <= actual quantity <= 99, 0 <= target threshold <= 99, arrays have identical length.

Rules

  • For each element at index i in actualArr:
    • If actualArr[i] >= thresholdArr[i]: add "<element>_RELEASED" to outArr.
    • Otherwise: add "<element>_REJECTED" to outArr.
  • Process for all elements and return outArr.

Sample Test Cases

# actualArr thresholdArr Expected Output (outArr)
1 [8, 3, 24, 28, 55, 44] [5, 5, 6, 25, 18, 42] ["8_RELEASED", "3_REJECTED", "24_RELEASED", "28_RELEASED", "55_RELEASED", "44_RELEASED"]
2 [6, 77, 66, 23] [5, 99, 50, 68] ["6_RELEASED", "77_REJECTED", "66_RELEASED", "23_REJECTED"]
3 [10, 15, 20, 21, 10] [20, 25, 31, 23, 15] ["10_REJECTED", "15_REJECTED", "20_REJECTED", "21_REJECTED", "10_REJECTED"]
4 [29, 10, 31, 55, 35] [20, 5, 20, 20, 10] ["29_RELEASED", "10_RELEASED", "31_RELEASED", "55_RELEASED", "35_RELEASED"]
Question 2 Screen Capture
Original Screen Capture - Question 2
✔ Java Solution Code — pfusingjava2.Solution
package pfusingjava2;

public class Solution {

    public static String[] auditBatches(int[] actualArr, int[] thresholdArr) {
        if (actualArr == null || thresholdArr == null) {
            return new String[0];
        }

        String[] outArr = new String[actualArr.length];

        for (int i = 0; i < actualArr.length; i++) {
            if (actualArr[i] >= thresholdArr[i]) {
                outArr[i] = actualArr[i] + "_RELEASED";
            } else {
                outArr[i] = actualArr[i] + "_REJECTED";
            }
        }

        return outArr;
    }
}

Question 3: Object Oriented Programming — UpSkill Certification

5 Marks Raw .md

"UpSkill" global educational organization offers training and certification. To get certified, users must take a prerequisite course and pay fees for both. Automate fee calculation based on the given class diagram.

Rebuilt High-Resolution UML Class Diagram

UpSkill Rebuilt UML Class Diagram
High-Resolution PNG (Click image to open vector SVG version)
Original Class Diagram Photo
Original Screen Photo - Class Diagram
Question 3 Details Screen
Original Screen Photo - Fee Calculation Rules

Class & Method Specifications

Class Method Name & Signature Implementation Details
Course identifyCourseFee(): int Code provided, no need to implement
Certification generateCertificationId(): void Code provided, no need to implement
identifyModeOfCertificationFee(): int Code provided, no need to implement
Employee
(extends Certification)
validateEmployee(): boolean Code provided, no need to implement
identifyDiscountPercent(certification: Certification): Integer Code provided, enhance as per requirement
calculateTotalFee(certification: Certification): void Need to be implemented
✔ Java Solution Code — Employee.java (extends Certification)
public class Employee extends Certification {
    private static String[][] courseTypeArr = {
        {"Concept Based", "Hands-On", "Hybrid"},
        {"200.0", "500.0", "1000.0"}
    };
    private String employeeName;
    private String employeeType;
    private String orgName;
    private String reqCourseType;

    public Employee(Course course, String modeOfCertification, String employeeName, 
                    String employeeType, String orgName, String reqCourseType) {
        super(course, modeOfCertification);
        this.employeeName = employeeName;
        this.employeeType = employeeType;
        this.orgName = orgName;
        this.reqCourseType = reqCourseType;
    }

    public boolean validateEmployee() {
        return employeeName != null && !employeeName.isEmpty();
    }

    // 1. Enhanced identifyDiscountPercent
    public Integer identifyDiscountPercent(Certification certification) {
        int discount = 0;
        if (this.validateEmployee()) {
            discount = 10;
        } else {
            return 0;
        }

        // Additional 5% discount if mode fee >= 350
        if (certification.identifyModeOfCertificationFee() >= 350) {
            discount += 5;
        }

        // Additional discount based on course fee
        int courseFee = certification.getCourse().identifyCourseFee();
        if (courseFee >= 4500) {
            discount += 10;
        } else if (courseFee >= 3500) {
            discount += 8;
        } else if (courseFee >= 2500) {
            discount += 5;
        }

        return discount;
    }

    // 2. Implemented calculateTotalFee
    public void calculateTotalFee(Certification certification) {
        double courseFee = certification.getCourse().identifyCourseFee();
        int basicFee = 5000;

        if (this.validateEmployee() && courseFee != -1.0) {
            double cost = 0.0;

            // Case-sensitive comparison in courseTypeArr
            for (int i = 0; i < courseTypeArr[0].length; i++) {
                if (courseTypeArr[0][i].equals(this.reqCourseType)) {
                    cost = Double.parseDouble(courseTypeArr[1][i]);
                    break;
                }
            }

            cost = cost + basicFee + courseFee;

            // Case-insensitive comparison for Trainee & Infosys deduction
            if ("Trainee".equalsIgnoreCase(this.employeeType) && "Infosys".equalsIgnoreCase(this.orgName)) {
                cost -= 2000.0;
            }

            certification.setCertificationFee(cost);
            certification.generateCertificationId();
        } else {
            certification.setCertificationFee(-1.0);
            certification.setCertificationId("NA");
        }
    }
}

Question 4: Data Structures — Queue Coupon Classification

5 Marks Raw .md

Problem Description

An e-commerce system stores coupons in the order they arrive. It also prevents misuse of blocked coupons. Write code in the given Java method to classify coupons based on the rules.

Input & Output Format

  • Input:
    • ArrayDeque<Integer> allowedQueue (coupons in sequence)
    • ArrayList<Integer> blockedList (blocked coupons)
  • Output: Returns ArrayDeque<String> outQueue.
  • Constraints: 0 <= number of coupons <= 10, 1000 <= coupon value <= 9999.

Classification Rules

For each coupon processed from front to rear:

  • If the coupon:
    • Appears more than once in allowedQueue, AND
    • Is not present in blockedList
    → Classify as "EC" (Eligible Coupon) and store as "<coupon>_EC" in a temporary data structure.
  • Otherwise: → Classify as "IC" (Invalid Coupon) and add "<coupon>_IC" directly to the output queue.
  • After processing all elements: → Append all elements from the temporary data structure in reverse order to the output queue.

Sample Test Cases

allowedQueue (Front→Rear) blockedList tempDataStructure outQueue (Front→Rear)
[4820, 1999, 4820, 2501, 2501, 6000, 3200, 3200] [2501, 7000] {"4820_EC", "4820_EC", "3200_EC", "3200_EC"} ["1999_IC", "2501_IC", "2501_IC", "6000_IC", "3200_EC", "3200_EC", "4820_EC", "4820_EC"]
[3000, 3000, 4200, 4200] [3000, 4200] - ["3000_IC", "3000_IC", "4200_IC", "4200_IC"]
Question 4 Screen Capture
Original Screen Capture - Question 4
Question 4 Sample Table
Sample Input & Output Table
✔ Java Solution Code — dsausingjava.Solution
package dsausingjava;

import java.util.*;

public class Solution {

    public static ArrayDeque classifyCoupons(ArrayDeque allowedQueue, ArrayList blockedList) {
        ArrayDeque outQueue = new ArrayDeque<>();

        if (allowedQueue == null || allowedQueue.isEmpty()) {
            return outQueue;
        }

        // Count frequency of coupons in allowedQueue
        Map freq = new HashMap<>();
        for (Integer c : allowedQueue) {
            freq.put(c, freq.getOrDefault(c, 0) + 1);
        }

        // Stack used as temporary data structure for LIFO reverse order
        Stack tempStack = new Stack<>();

        for (Integer coupon : allowedQueue) {
            boolean moreThanOnce = freq.get(coupon) > 1;
            boolean isBlocked = (blockedList != null && blockedList.contains(coupon));

            if (moreThanOnce && !isBlocked) {
                tempStack.push(coupon + "_EC");
            } else {
                outQueue.add(coupon + "_IC");
            }
        }

        // Append in reverse order
        while (!tempStack.isEmpty()) {
            outQueue.add(tempStack.pop());
        }

        return outQueue;
    }
}