Skip to main content

Featured

Adobe Experience Manager - Create an OSGI Configuration

 In this article, let's create an OSGi configuration, configure it and use it in AEM code. So now let's get started with the creation of an OSGi configuration. Technical details and Assumptions: All the following details are tested in AEM version 6.5.8, Java version 11.0.2 Creation of OSGi configuration: To create an OSGi configuration we need to create an ObjectClassDefinition. I have included a sample OCD configuration, which can be used as a reference to create one. The next step would be to create an interface and an implementation that can help fetch the OSGi configurations.  Interface: Implementation: Let's try to use the OSGi configuration created so far in Models/Servlets. For demonstration purposes, I used AEM Models here, but the same can be implemented in Servlets too. Now that we have created the OSGi configuration. Once building the code, we should be able to see the OSGi configuration in the web console (http://localhost:4502/system/console/configMgr) C...

A Small Step Toward Calculators

Sridhar has a string of the form x+y or x-y. Here, and are single-digit non negative integers. His task is to perform the addition or subtraction accordingly and print the result.

As a newbie programmer, Sridhar is struggling to finish the task. Can you help him?

Input Format

In a single line, you will be given the string.

Constraints

The string contains exactly characters of the form x+y or x-y.

Output Format

In a single line, print the result of the operation.

Sample Input 0
0+1
Sample Output 0
1
Program
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

    static int solve(String opr) {
        int x,y;char sym;
        int res;
        x = Character.getNumericValue(opr.charAt(0));
        y = Character.getNumericValue(opr.charAt(2));
        sym = opr.charAt(1);
        if(sym == '+')
            res = x + y;
        else
            res = x - y;
        return res;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String opr = in.next();
        int result = solve(opr);
        System.out.println(result);
        in.close();
    }
}

Comments

Post a Comment

Popular Posts