Mapping help - substring calculations

Hi,
I need to do mapping like below
for eg., if my source is coming 12345.000 then my target should remove the decimal and the value should be 12345000
also it the source is 0.000 then target should be 0000.
how can we maintain this at runtime...pls help me out

Hi,
you can use the replaceString function (replace "." with "" (empty string)).
Regards,
Koen

Similar Messages

  • XSLT mapping Help Required.

    XSLT mapping Help Required.
    Hi Experts,
    I am New to XSLT Mapping. I am practising the below Example:
    InputXML File:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="Persons111.xsl"?>
    <ns0:MT_XSLT_Source xmlns:ns0="http://XYZ.com/gen">
    <Person>
    <FirstName>Anshul</FirstName>
    <LastName>Chowdhary</LastName>
    <Gender>Male</Gender>
    <Address>
    <Street>2nd Main</Street>
    <Houseno>83/b</Houseno>
    <City>Mysore</City>
    </Address> </Person>
    </ns0:MT_XSLT_Source>
    XSL StyleSheet File:
    <?xml version='1.0' encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://XYZ.com/Gen"
    Xmlns:ns1=”http://XYZ.com/Test”>
    <xsl:template match="/">
    <ns1:MT_XSLT_Target>
    <Title> <xsl:value-of select="ns0:MT_XSLT_Source/Person/Gender"/> </Title>
    <Name> <xsl:value-of select="concat(concat(ns0:MT_XSLT_Source/Person/FirstName,' '), ns0:MT_XSLT_Source/Person/LastName)"/>
    </Name>
    <Street> <xsl:value-of select="concat(concat(ns0:Mt_XSLT_Source/Person/Address/Houseno,' '),
    ns0:Mt_XSLT_Source/Person/Address/Street)"/> </Street>
    <City> <xsl:value-of select="ns0:Mt_XSLT_Source/Person/Address/City"/> </City>
    </ns1:MT_XSLT_Target>
    </xsl:template>
    </xsl:stylesheet>
    The Desired Output shuold be:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns1:MT_XSLT_Target xmlns:ns1="http://XYZ.com/Test">
    <Title>Male</Title>
    <Name>Anshul Chowdhary</Name>
    <Street>83/b 2nd Main</Street>
    <City>Mysore</City>
    </ns1:MT_XSLT_Target>
    I have refered the xsl in xml and i am getting the below Oupt in a Single line like this:
    Anshul Chowdhary Male 2nd Main 83/b Mysore
    I am Unable to display in Target XML Fomrat as shown above. Please check and do the needful.
    Regards,
    GIRIDHAR

    Hi,
    I have used below for testing.
    Input xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="Persons111.xsl"?>
    <ns0:MT_XSLT_Source xmlns:ns0="http://XYZ.com/gen">
    <Person>
    <FirstName>Anshul</FirstName>
    <LastName>Chowdhary</LastName>
    <Gender>Male</Gender>
    <Address>
    <Street>2nd Main</Street>
    <Houseno>83/b</Houseno>
    <City>Mysore</City>
    </Address> </Person>
    </ns0:MT_XSLT_Source>
    xsl code:
    <?xml version='1.0' encoding="UTF-8"?> 
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://XYZ.com/gen" 
        xmlns:ns1="http://XYZ.com/Test"> 
        <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 
        <xsl:template match="/"> 
            <ns1:MT_XSLT_Target> 
                <Title> <xsl:value-of select="ns0:MT_XSLT_Source/Person/Gender"/> </Title> 
                <Name> <xsl:value-of select="concat(concat(ns0:MT_XSLT_Source/Person/FirstName,' '), ns0:MT_XSLT_Source/Person/LastName)"/> 
                </Name> 
                <Street> <xsl:value-of select="concat(concat(/ns0:MT_XSLT_Source/Person/Address/Houseno,' '), 
                    /ns0:MT_XSLT_Source/Person/Address/Street)"/> </Street> 
                <City> <xsl:value-of select="/ns0:MT_XSLT_Source/Person/Address/City"/> </City> 
            </ns1:MT_XSLT_Target> 
        </xsl:template> 
    </xsl:stylesheet>
    For testing in PI ,change the extension from .txt to .xsl and zip it and upload into PI as an imported archive .
    Regards
    Venkat

  • Mapping Help for replacing source value

    Mapping Help for replacing source value
    Posted: Mar 14, 2006 1:06 AM    Reply 
    Hi all,
    I am unable to do transform the source value to required target value,
    From Source ADDRESS_TYPE = 'HOME' should be replaced with 03 to target field ANSSA, and 'MAIL' to be replaced with 05, I am trying to do it but i am unable to handle it, please give u r valuable suggestions,
    The source structure is like this,
    - <Event ID="239" TRANS_TYPE="ADR">
    <PersAddr GEO_LOC_CD="US" EMPLID="29" ADDRESS_TYPE="HOME" EFFDT="02/15/2006" ADDRESS1="92nd Floor" ADDRESS2="812backstreet" ADDRESS3="" ADDRESS4="" CITY="London" COUNTY="" STATE="AN" POSTAL="EC2N 4AG1" COUNTRY="GBR" KEY1="29" KEY2="HOME" KEY3="02/10/2006" />
    <PersAddr GEO_LOC_CD="US" EMPLID="29" ADDRESS_TYPE="MAIL" EFFDT="02/15/2006" ADDRESS1="92nd Floor" ADDRESS2="812backstreet" ADDRESS3="" ADDRESS4="" CITY="London" COUNTY="" STATE="AN" POSTAL="EC2N 4AG1" COUNTRY="GBR" KEY1="29" KEY2="MAIL" KEY3="02/10/2006" />
    </Event>
    REGARDS,
    sridhar

    Hi,
    This can be done using user-defined function as well.
    Code the function as...
    if(Addr_Type.equals("HOME"))
       return "03";
    else if(Addr_Type.equals("MAIL"))
       return "05";
    else
       return "Invalid Address Type";
    Here, Addr_Type is Input String Argument for this function.
    Map this function between ADDRESS_TYPE and ANSSA.
    Regards,
    Uma

  • Mapping help UDF

    hello experts.
    the standard functions are not working for the number of occurrences.
    below is the structure.
    Root 0....unbounded                                                        Root 0 ...unbounded.
       events 0...unbounded
           countries 1...1
           total 0....unbounded.
              amount 1
              totals
    Now the condition is.....if countries tag is not available and  amount is zero and under total tag we have totals.....if the tag not there.......target side root should not come.
    i have done mapping.
    countries ----exists-------------------------------------
    amount-------
                      equals-----not------                                        and--------createif----removecontext-----root.
    constant-------                               and ---------------
       (0)
       totals --------exist------------
    regards,
    chinna

    Hi,
    check this mapping help...
    it looks both the threads are same.
    Regards,
    Muni.

  • Need Mapping Help: Generate index if value comes

    Hi Experts,
    I need mapping help to generate index if value comes form source. we have 4 fields in item level of source and target side we have to pass the these filed values and sequence number.
    below given the structures:
    Source:              Target:
    Item                    Item
       A1                      Text
        A2                      Seq_No
        A3
        A4
    my requirement is if A1 filed values comes from source we should pass to text and pass seq_no to constant-1, same as A2,A3 and A4 filed values also we should pass to text and seq_no for A2 is 2 and A3 is 3 and A4 is 4. suppose if A1 value is not coming from source we should pass seq_no for A2 is 1. if A1 and A3 filed values are not coming from source then we should pass seq_no for A2 and A3 are 1 and 2.
    can you please help me how to achieve this. appreciate for your support.
    Regards,
    Sanjay.

    Hi Sanjay,
                      you can  try this mapping
    1. Generate the target 4  ITEM's  by duplicating the subtree as shown below 3 times.
    Now create the each target item starting from first by mapping them to A1,A2,A3 and A4 respectively. I have shown the first ITEM mapping above. similarly you can map A2 to ITEM[1],
    A3 to ITEM[2] and A4 to ITEM[3].
    2. Now you can map the A* fields to Text one to one as shown below
    Please repeat the same for A2,A3 and A4 to respective Text fields.
    3. 
    First seq_no field as shown
    and similarly others as shown
    Regards
    Anupam

  • Help in Calculation Script

    I need your help in calculation script: Using 9.3.1 version
    In below script , I have to write same code for total 10 account members used in the same place A and all 10 accounts members are level 0 children of 1 parent.
    A = A + B / C*D
    I need to write a code where 10 Account members can be used during calculation in place of A.
    Please can you help me on this query .. How to achieve this requirement ...
    Regards
    Vishal

    Using my Very Favorite Essbase Database In The Whole Wide World, aka Sample.Basic, I wrote the following nonsense code snippet:
    FIX(@RELATIVE("Profit", 0), @LEVMBRS("Product", 0), @LEVMBRS("Market", 0), @LEVMBRS("Year", 0))
         "Actual" = "Actual" + "Actual"->"Opening Inventory" / "Actual"->"Additions" * "Actual"->"Ending Inventory" ;
    ENDFIXDon't focus on why you would never ever want to do the above with inventory, just look at the code.
    The code does work.
    Before:
              100-10     New York     Actual
    Jan               Sales     679          
                   COGS     271          
              Margin     408          
                   Marketing     94          
                   Payroll     51          
                   Misc     0          
              Total Expenses     145          
         Profit     263          
              Opening Inventory     2101          
              Additions     644          
              Ending Inventory     2066          After
              100-10     New York     Actual
    Jan               Sales     7419.164596          
                   COGS     7011.164596          
              Margin     408          
                   Marketing     6834.164596          
                   Payroll     6791.164596          
                   Misc     6740.164596          
              Total Expenses     20365.49379          
         Profit     -19957.49379          
              Opening Inventory     2101          
              Additions     644          
              Ending Inventory     2066          I can't remember if your to be affected members are under a common parent or not. If the latter, use a UDA to go after the members.
    Oh yes, this code violates one of my personal design considerations -- it modifies the source data so it can only be run once. That is really dangerous but the choice is yours.
    Regards,
    Cameron Lackpour

  • Help with calculations in XMLP Template

    Hi,
    I would like to get some guidance on how the below could be done in XMLP. I am getting the 'Amount' column from FSG and would like to calculate the percentage in the template. Is it possible to calculate rows and store results in column like in the example below in XMLP? Many thanks for your help.
    Type-------Amount-----%
    Gross-----------10-----166.7 (Gross/Net*100)
    Discount---------4-------66.7 (Discount/Net*100)
    ======================
    Net (G-D)--------6-----100.0 (Net/Net*100) or (Gross% - Discount%)

    Hi Hazan,
    I have done a similar Gross Margin Report using XMLP 5.5.
    I have used the concept of variables to store temporary values in my report and carry out complex calculations.
    Please let me know what version of XMLP are you using?
    Some of my form fields containing variables look like this:
    <?xdoxslt:set_variable($_XDOCTX, ’Sum1’, CS_TCOST + CS_TCOST1)?>
    <?xdoxslt:get_variable($_XDOCTX, ’Sno’ )?> <?xdoxslt:set_variable($_XDOCTX, ’Sno’, xdoxslt:get_variable($_XDOCTX, ’Sno’) + 1)?>
    <?xdofx:if(CS_TSELL + CS_TSELL1) <= 0 then
    xdoxslt:set_variable($_XDOCTX, ’Sum1’, 1)
    end if?>
    I am not sure if you are looking at this or not. Do let me know if this solves the purpose and need be required some help :-o)
    HTH,
    Nitin

  • Need help with calculating interest

    Hey im trying to find out where my calculations are screwing up on the interest is coming up wrong but i am unable to find out where. After every month its suppose to be deposit - withdrawl * monthly interest rate and then add that total to the new month etc... any help will be appreciated. Heres my class and test
    public class SavingsAccount
        private double bal;
        private double intRate;
    The constructor initializes an object with a
    balance and an annual interest rate.
    @param bal The account balance.
    @param intRate The annual interest rate.
        public SavingsAccount(double bal, double intRate)
        bal= 0.0;
        intRate = 0.0;
        The withdraw method withdraws an amount from
        the account.
        @param amount The amount to withdraw.
        public void withdraw(double amount)
            bal -= amount;
        The deposit method deposits an amount into
        the account.
        @param amount The amount to deposit.
        public void deposit(double amount)
            bal += amount;
        The addInterest method calculates the monthly
        interest and adds it to the account balance.
        public void addInterest()
        // Get the monthly interest rate.
        // Calculate the last amount of interest earned.
        // Add the interest to the balance.
         intRate = bal * (intRate/12);
         bal += intRate;
        The getBalance method returns the account balance.
        @return The account balance.
        public double getBalance()
        return bal;
        The getInterestRate method returns the annual
        interest rate.
        @return The annual interest rate.
        public double getInterestRate()
        return intRate;
        The getLastInterest method returns the last amount
        of interest earned.
        @return The last amount of interest earned.
        public double getLastInterest()
        return bal;
    import java.util.Scanner;
    import java.text.DecimalFormat;
    public class SavingsAccountTest
        public static void main(String args[])
        // Annual interest rate
           double intRate;
        // Starting balance
           double startBal;
        // Amount of deposits for a month
           double deposit;
           double totalDeposit;
        // Amount withdrawn in a month
           double withdrawn;
           double totalWithdrawn;
        // Interest earned
           double intEarned = 0;
        // Deposit accumulator
           deposit = 0.0;
           totalDeposit = 0.0;
        // Withdrawal accumulator
           withdrawn =0.0;
           totalWithdrawn = 0.0;
        // Months that have passed
           double months;
        // Create a Scanner object for keyboard input.
           Scanner keyboard = new Scanner(System.in);
        // Get the starting balance.
           System.out.println("What is your account's starting balance");
           startBal = keyboard.nextDouble();
           while (startBal < 0)
               startBal=0;
        // Get the annual interest rate.
           System.out.println("What is the annual interest rate?");
           intRate = keyboard.nextDouble();
           while (intRate <= 0 )
               intRate = 0;
        // Create a SavingsAccount object.
           SavingsAccount account = new SavingsAccount(0.0, 0.0);
        // Get the number of months that have passed.
           System.out.println("How many months have passed since the " +
                              "account has opened? ");
           months = keyboard.nextDouble();
           while (months <= 0)
               months = 1;
        // Get the deposits and withdrawals for each month.
        for (int i = 1; i <= months; i++)
        // Get the deposits.
           System.out.println("Enter the amount deposited during month " + i);
           deposit= keyboard.nextDouble();
           totalDeposit += deposit;
           while (deposit <=0)
               deposit = 0;
        // Get the withdrawals.
           System.out.println("Enter the amount withdrawn during month " + i);
           withdrawn = keyboard.nextDouble();
           totalWithdrawn += withdrawn;
           while (withdrawn <= 0)
               withdrawn = 0;
        // Add the deposits to the account.
           startBal += deposit;
        // Subtract the withdrawals.
           startBal -= withdrawn;
        // Add the monthly interest.
           intRate = startBal * intRate/12;
           startBal += intRate;
        // Accumulate the amount of interest earned.
           intRate += intEarned;
        // Create a DecimalFormat object for formatting output.
        DecimalFormat dollar = new DecimalFormat("#,##0.00");
        // Display the totals and the balance.
        System.out.println("Total deposited: " + dollar.format(totalDeposit));
        System.out.println("Total withdrawn: " + dollar.format(totalWithdrawn));
        System.out.println("Total interest earned: " + dollar.format(intEarned));
        System.out.println("Account balance: " + dollar.format(startBal));
    }

    Ok this is what i have fixed up so far but im still having trouble calculating the interest. Problem1) We were given the skeleton to the class and demo. I cannot figure out what to enter in getLastInterest.(completely lost all i need is hint) 2)When i try to get the Total money deposited and i call the account.deposit(balance) it keeps on giving an error void not allowed. Any help is appreciated
    public class SavingsAccount
        private double balance;
        private double interest;
        private double intEarned;
        The constructor initializes an object with a
        balance and an annual interest rate.
        @param bal The account balance.
        @param intRate The annual interest rate.
        public SavingsAccount(double bal, double intRate)
        balance = bal;
        interest = intRate;
        The withdraw method withdraws an amount from
        the account.
        @param amount The amount to withdraw.
        public void withdraw(double amount)
            balance -= amount;
        The deposit method deposits an amount into
        the account.
        @param amount The amount to deposit.
        public void deposit(double amount)
            balance += amount;
        The addInterest method calculates the monthly
        interest and adds it to the account balance.
        public void addInterest()
        // Get the monthly interest rate.
        // Calculate the last amount of interest earned.
        // Add the interest to the balance.
         interest = balance * (interest/12);
         interest = intEarned;
         balance += interest;
        The getBalance method returns the account balance.
        @return The account balance.
        public double getBalance()
        return balance;
        The getInterestRate method returns the annual
        interest rate.
        @return The annual interest rate.
        public double getInterestRate()
        return interest;
        The getLastInterest method returns the last amount
        of interest earned.
        @return The last amount of interest earned.
        public double getLastInterest()
        return intEarned;
    import java.util.Scanner;
    import java.text.DecimalFormat;
    public class SavingsAccountTest
        public static void main(String args[])
        // Annual interest rate
           double intRate;
        // Starting balance
           double balance;
        // Amount of deposits for a month
           double deposit;    
        // Amount withdrawn in a month
           double withdraw;
        // Interest earned
           double intEarned = 0;
        // Deposit accumulator
           deposit = 0.0;  
        // Withdrawal accumulator
           withdraw =0.0;    
        // Months that have passed
           double months;
        // Create a Scanner object for keyboard input.
           Scanner keyboard = new Scanner(System.in);
        // Get the starting balance.
           System.out.println("What is your account's starting balance");
           balance = keyboard.nextDouble();
           if (balance < 0)
               balance=0;
        // Get the annual interest rate.
           System.out.println("What is the annual interest rate?");
           intRate = keyboard.nextDouble();
           if (intRate <= 0 )
               intRate = 0;
        // Create a SavingsAccount object. Cannot find Symbol!!
           SavingsAccount account = new SavingsAccount(balance,intRate);
        // Get the number of months that have passed.
           System.out.println("How many months have passed since the " +
                              "account has opened? ");
           months = keyboard.nextDouble();
           if (months <= 0)
               months = 1;
        // Get the deposits and withdrawals for each month.
        for (int i = 1; i <= months; i++)
        // Get the deposits.
           System.out.println("Enter the amount deposited during month " + i);
           deposit= keyboard.nextDouble();
           account.deposit(deposit);
           if (deposit <=0)
               deposit = 0;
        // Get the withdrawals.
           System.out.println("Enter the amount withdrawn during month " + i);
           withdraw = keyboard.nextDouble();
           account.withdraw(withdraw);
           if (withdraw <= 0 || withdraw >= balance)
               withdraw = 0;
        // Add the deposits to the account.
           account.deposit(balance);
        // Subtract the withdrawals.
           account.withdraw(balance);
        // Add the monthly interest.
           account.addInterest();
        // Accumulate the amount of interest earned. ????? Wrong
           intRate += intEarned;
        // Create a DecimalFormat object for formatting output.
        DecimalFormat dollar = new DecimalFormat("#,##0.00");
        // Display the totals and the balance.
        System.out.println("Total deposited: " + dollar.format(account.deposit(balance)));
        System.out.println("Total withdrawn: " + dollar.format(account.withdraw(balance)));
        System.out.println("Total interest earned: " + dollar.format(account.addInterest()));
        System.out.println("Account balance: " + dollar.format(account.getBalance()));
    }

  • Need help in calculating a total from flowable table

    I've tried everything to include using the example from the tutorial on creating a flowable purchase order form.  My problem is that I can't get the total field to reflect a total.  I'd be willing to send the form to anyone willing to shed some light and provide a solution.
    Thanks

    Paul, I don't believe that I'm grasping exactly what you are saying.  I have several forms at work that I've designed (none with flowable content however) with calculations, it's just I can't seem to get this one to do what I need.  So.... let me plead ignorance on this one for the moment.
    Actually, I have the one row that accepts data, then if the user wants to, they can click on the add item button to add another instance.  Even after entering the one rows data, that amount does not reflect in the total field.  You would likely need to see the form possibly, and if so, let me know.  I'd be glad to have your help in any way you could provide it.
    Mike

  • SSRS Heat Map help

    Hi 
    I have SQL 2012 and while having a play around with a report I wanted to use a heat map ( or treemap ) as I believe it was called.
    Any way I found that it one of the posts here points you to
    http://www.sqljason.com/2012/03/heat-maps-for-ssrs-using-map-control.html
    So I downloaded the dll
    Went to my dw and executed the following
    CREATE ASSEMBLY HeatMap from 'c:\HeatMap\HeatMap.dll' WITH PERMISSION_SET = SAFE
    CREATE PROCEDURE dbo.CreateHeatMap (@Width real, @Height real, @SqlStrng nvarchar(4000))
    AS
    EXTERNAL NAME HeatMap.StoredProcedures.TreeMapGeography
    Then executed the proc
    DECLARE    @return_value int
    EXEC    @return_value = [dbo].[CreateHeatMap]
            @Width = 20,
            @Height = 25,
            @SqlStrng = N'Select WKDAY ,  SUM (TotalTransactions) ts FROM ReportingDW..f_transactionstolive group by WKDAY  '
    SELECT    'Return Value' = @return_value
    when It comes up with the following
    Msg 6522, Level 16, State 1, Procedure CreateHeatMap, Line 0
    A .NET Framework error occurred during execution of user-defined routine or aggregate "CreateHeatMap":
    System.FormatException: Input string was not in a correct format.
    System.FormatException:
       at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
       at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
       at StoredProcedures.TreeMap..ctor(DataTable TreeMapData, Single Height, Single Width)
       at StoredProcedures.TreeMapGeography(SqlSingle Height, SqlSingle Width, SqlString select)
    Im now not sure what to do any help would be great .
    I just want a simple square treemap or heat map that highlights the size of each process in rectangles and cant believe how difficult it is.
    Many Thanks
    Robert

    Hi Robert,
    In your case, the issue may be due to that you have create an assembly, and then you register the assembly on a Microsoft SQL Server database. Then, you install a different version of the assembly in the Global Assembly Cache (GAC).
    In order to work around the issue, please use the ALTER ASSEMBLY statement to update the assembly in the database. If the problem still exists after you do this, drop the assembly from the database, and then register the new version of the assembly in the
    database.
    There is a similar issue for your reference.
    http://support.microsoft.com/kb/949080/en-us
    If the issue is persist, I recommend you post the issue in the following forum:
    .NET Framework inside SQL Server
    It is appropriate and more experts will assist you.
    Regards,
    Alisa Tang
    If you have any feedback on our support, please click
    here.
    Alisa Tang
    TechNet Community Support

  • Need help with calculator project for an assignment...

    Hi all, I please need help with my calculator project that I have to do for an assignment.
    Here is the project's specifications that I need to do"
    """Create a console calculator applicaion that:
    * Takes one command line argument: your name and surname. When the
    program starts, display the date and time with a welcome message for the
    user.
    * Display all the available options to the user. Your calculator must include
    the arithmetic operations as well as at least five scientific operations of the
    Math class.
    -Your program must also have the ability to round a number and
    truncate it.
    -When you multiply by 2, you should not use the '*' operator to perform the
    operation.
    -Your program must also be able to reverse the sign of a number.
    * Include sufficient error checking in your program to ensure that the user
    only enters valid input. Make use of the String; Character, and other
    wrapper classes to help you.
    * Your program must be able to do conversions between decimal, octal and
    hex numbers.
    * Make use of a menu. You should give the user the option to end the
    program when entering a certain option.
    * When the program exits, display a message for the user, stating the
    current time, and calculate and display how long the user used your
    program.
    * Make use of helper classes where possible.
    * Use the SDK to run your program."""
    When the program starts, it asks the user for his/her name and surname. I got the program to ask the user again and again for his/her name and surname
    when he/she doesn't insert anything or just press 'enter', but if the user enters a number for the name and surname part, the program continues.
    Now my question is this: How can I restrict the user to only enter 'letters' (and spaces of course) but allow NO numbers for his/her surname??
    Here is the programs code that I've written so far:
    {code}
    import java.io.*;
    import java.util.*;
    import java.text.*;
    public class Project {
         private static String nameSurname = "";     
         private static String num1 = null;
         private static String num2 = null;
         private static String choice1 = null;
         private static double answer = 0;
         private static String more;
         public double Add() {
              answer = (Double.parseDouble(num1) + Double.parseDouble(num2));
              return answer;
         public double Subtract() {
              answer = (Double.parseDouble(num1) - Double.parseDouble(num2));
              return answer;
         public double Multiply() {
              answer = (Double.parseDouble(num1) * Double.parseDouble(num2));
              return answer;
         public double Divide() {
              answer = (Double.parseDouble(num1) / Double.parseDouble(num2));
              return answer;
         public double Modulus() {
              answer = (Double.parseDouble(num1) % Double.parseDouble(num2));
              return answer;
         public double maximumValue() {
              answer = (Math.max(Double.parseDouble(num1), Double.parseDouble(num2)));
              return answer;
         public double minimumValue() {
              answer = (Math.min(Double.parseDouble(num1), Double.parseDouble(num2)));
              return answer;
         public double absoluteNumber1() {
              answer = (Math.abs(Double.parseDouble(num1)));
              return answer;
         public double absoluteNumber2() {
              answer = (Math.abs(Double.parseDouble(num2)));
              return answer;
         public double Squareroot1() {
              answer = (Math.sqrt(Double.parseDouble(num1)));
              return answer;
         public double Squareroot2() {
              answer = (Math.sqrt(Double.parseDouble(num2)));
              return answer;
         public static String octalEquivalent1() {
              int iNum1 = Integer.parseInt(num1);
    String octal1 = Integer.toOctalString(iNum1);
    return octal1;
         public static String octalEquivalent2() {
              int iNum2 = Integer.parseInt(num2);
              String octal2 = Integer.toOctalString(iNum2);
              return octal2;
         public static String hexadecimalEquivalent1() {
              int iNum1 = Integer.parseInt(num1);
              String hex1 = Integer.toHexString(iNum1);
              return hex1;
         public static String hexadecimalEquivalent2() {
              int iNum2 = Integer.parseInt(num2);
              String hex2 = Integer.toHexString(iNum2);
              return hex2;
         public double Round1() {
              answer = Math.round(Double.parseDouble(num1));
              return answer;
         public double Round2() {
              answer = Math.round(Double.parseDouble(num2));
              return answer;
              SimpleDateFormat format1 = new SimpleDateFormat("EEEE, dd MMMM yyyy");
         Date now = new Date();
         SimpleDateFormat format2 = new SimpleDateFormat("hh:mm a");
         static Date timeIn = new Date();
         public static long programRuntime() {
              Date timeInD = timeIn;
              long timeOutD = System.currentTimeMillis();
              long msec = timeOutD - timeInD.getTime();
              float timeHours = msec / 1000;
                   return (long) timeHours;
         DecimalFormat decimals = new DecimalFormat("#0.00");
         public String insertNameAndSurname() throws IOException{
              boolean inputCorrect = false;
                   while (inputCorrect == false) {
                        while (nameSurname == null || nameSurname.length() == 0) {
                             for (int i = 0; i < nameSurname.length(); i++) {
                             if ((nameSurname.charAt(i) > 'a') && (nameSurname.charAt(i) < 'Z')){
                                       inputCorrect = true;
                        else{
                        inputCorrect = false;
                        break;
                        try {
                             BufferedReader inStream = new BufferedReader (new InputStreamReader(System.in));
                             System.out.print("Please enter your name and surname: ");
                             nameSurname = inStream.readLine();
                             inputCorrect = true;
                        }catch (IOException ex) {
                             System.out.println("You did not enter your name and surname, " + nameSurname + " is not a name, please enter your name and surname :");
                             inputCorrect = false;
                        System.out.println("\nA warm welcome " + nameSurname + " ,todays date is: " + format1.format(now));
                        System.out.println("and the time is now exactly " + format2.format(timeIn) + ".");
                        return nameSurname;
              public String inputNumber1() throws IOException {
              boolean inputCorrect = false;
                   while (inputCorrect == false) {
                        try {
                             BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
                             System.out.print("\nPlease enter a number you want to do a calculation with and hit <ENTER>: ");
                             num1 = br.readLine();
                             double number1 = Double.parseDouble(num1);
                             System.out.println("\nThe number you have entered is: " + number1);
                             inputCorrect = true;
                        } catch (NumberFormatException nfe) {
                             System.out.println("\nYou did not enter a valid number: " + "\""+ num1 + "\" is not a number!!");
                             inputCorrect = false;
                        return num1;
         public String calculatorChoice() throws IOException {
              System.out.println("Please select an option of what you would like to do with this number from the menu below and hit <ENTER>: ");
              System.out.println("\n*********************************************");
              System.out.println("---------------------------------------------");
              System.out.println("Please select an option from the list below: ");
              System.out.println("---------------------------------------------");
              System.out.println("1 - Add");
              System.out.println("2 - Subtract");
              System.out.println("3 - Multiply");
              System.out.println("4 - Divide (remainder included)");
              System.out.println("5 - Maximum and minimum value of two numbers");
              System.out.println("6 - Squareroot");
              System.out.println("7 - Absolute value of numbers");
              System.out.println("8 - Octal and Hexadecimal equivalent of numbers");
              System.out.println("9 - Round numbers");
              System.out.println("0 - Exit program");
              System.out.println("**********************************************");
              boolean inputCorrect = false;
                   while (inputCorrect == false) {
                        try {
                             BufferedReader inStream = new BufferedReader (new InputStreamReader(System.in));
                             System.out.print("Please enter your option and hit <ENTER>: ");
                             choice1 = inStream.readLine();
                             int c1 = Integer.parseInt(choice1);
                             System.out.println("\nYou have entered choice number: " + c1);
                             inputCorrect = true;
                        } catch (NumberFormatException nfe) {
                             System.out.println("You did not enter a valid choice number: " + "\""+ choice1 + "\" is not in the list!!");
                             inputCorrect = false;
                        return choice1;
         public String inputNumber2() throws IOException {
              boolean inputCorrect = false;
                   while (inputCorrect == false) {
                        try {
                             BufferedReader br2 = new BufferedReader (new InputStreamReader(System.in));
                             System.out.print("\nPlease enter another number you want to do the calculation with and hit <ENTER>: ");
                             num2 = br2.readLine();
                             double n2 = Double.parseDouble(num2);
                             System.out.println("\nThe second number you have entered is: " + n2);
                             System.out.println("\nYour numbers are: " + num1 + " and " + num2);
                             inputCorrect = true;
                        } catch (NumberFormatException nfe) {
                             System.out.println("You did not enter a valid number: " + "\""+ num2 + "\" is not a number!!");
                             inputCorrect = false;
                        return num2;
         public int Calculator() {
              int choice2 = (int) Double.parseDouble(choice1);
              switch (choice2) {
                        case 1 :
                             Add();
                             System.out.print("The answer of " + num1 + " + " + num2 + " is: " + decimals.format(answer));
                             break;
                        case 2 :
                             Subtract();
                             System.out.print("The answer of " + num1 + " - " + num2 + " is: " + decimals.format(answer));
                             break;
                        case 3 :
                             Multiply();
                             System.out.print("The answer of " + num1 + " * " + num2 + " is: " + decimals.format(answer));
                             break;
                        case 4 :
                             Divide();
                             System.out.print("The answer of " + num1 + " / " + num2 + " is: " + decimals.format(answer));
                             Modulus();
                             System.out.print(" and the remainder is " + decimals.format(answer));
                             break;
                        case 5 :
                             maximumValue();
                             System.out.println("The maximum number between the numbers " + num1 + " and " + num2 + " is: " + decimals.format(answer));
                             minimumValue();
                             System.out.println("The minimum number between the numbers " + num1 + " and " + num2 + " is: " + decimals.format(answer));
                             break;
                        case 6 :
                             Squareroot1();
                             System.out.println("The squareroot of value " + num1 + " is: " + decimals.format(answer));
                             Squareroot2();
                             System.out.println("The squareroot of value " + num2 + " is: " + decimals.format(answer));
                             break;
                        case 7 :
                             absoluteNumber1();
                             System.out.println("The absolute number of " + num1 + " is: " + decimals.format(answer));
                             absoluteNumber2();
                             System.out.println("The absolute number of " + num2 + " is: " + decimals.format(answer));
                             break;
                        case 8 :
                             octalEquivalent1();
                             System.out.println("The octal equivalent of " + num1 + " is: " + octalEquivalent1());
                             octalEquivalent2();
                             System.out.println("The octal equivalent of " + num2 + " is: " + octalEquivalent2());
                             hexadecimalEquivalent1();
                             System.out.println("\nThe hexadecimal equivalent of " + num1 + " is: " + hexadecimalEquivalent1());
                             hexadecimalEquivalent2();
                             System.out.println("The hexadecimal equivalent of " + num2 + " is: " + hexadecimalEquivalent2());
                             break;
                        case 9 :
                             Round1();
                             System.out.println("The rounded number of " + num1 + " is: " + decimals.format(answer));
                             Round2();
                             System.out.println("The rounded number of " + num2 + " is: " + decimals.format(answer));
                             break;
                        case 0 :
                             if (choice2 == 0) {
                                  System.exit(1);
                             break;
                   return choice2;
              public String anotherCalculation() throws IOException {
                   boolean inputCorrect = false;
                   while (inputCorrect == false) {
                             try {                              
                                  BufferedReader br3 = new BufferedReader (new InputStreamReader(System.in));
                                  System.out.print("\nWould you like to do another calculation? Y/N ");
                                  more = br3.readLine();
                                  String s1 = "y";
                                  String s2 = "Y";
                                  if (more.equals(s1) || more.equals(s2)) {
                                       inputCorrect = true;
                                       while (inputCorrect = true){
                                            inputNumber1();
                                            System.out.println("");
                                            calculatorChoice();
                                            System.out.println("");
                                            inputNumber2();
                                            System.out.println("");
                                            Calculator();
                                            System.out.println("");
                                            anotherCalculation();
                                            System.out.println("");
                                            inputCorrect = true;
                                  } else {
                                       System.out.println("\n" + nameSurname + " thank you for using this program, you have used this program for: " + decimals.format(programRuntime()) + " seconds");
                                       System.out.println("the program will now exit, Goodbye.");
                                       System.exit(0);
                             } catch (IOException ex){
                                  System.out.println("You did not enter a valid answer: " + "\""+ more + "\" is not in the list!!");
                                  inputCorrect = false;
              return more;
         public static void main(String[] args) throws IOException {
              Project p1 = new Project();
              p1.insertNameAndSurname();
              System.out.println("");
              p1.inputNumber1();
              System.out.println("");
              p1.calculatorChoice();
              System.out.println("");
              p1.inputNumber2();
              System.out.println("");
              p1.Calculator();
                   System.out.println("");
                   p1.anotherCalculation();
                   System.out.println("");
    {code}
    *Can you please run my code for yourself and have a look at how this program is constructed*
    *and give me ANY feedback on how I can better this code(program) or if I've done anything wrong from your point of view.*
    Your help will be much appreciated.
    Thanks in advance

    Smirre wrote:
    Now my question is this: How can I restrict the user to only enter 'letters' (and spaces of course) but allow NO numbers for his/her surname??You cannot restrict the user. It is a sad fact in programming that the worst bug always sits in front of the Computer.
    What you could do is checking the input string for numbers. If it contains numbers, just reprompt for the Name.
    AND you might want to ask yourself why the heck a calculator needs to know the users Name.

  • Need Help in Calculation of Paid and Unpaid Break in Daily Work Schedule

    hai,
    I am a student of SAP-HCM. I am having problem with the calculation
    in Paid and Unpaid Break in Daily work schedule (Time Management).
    Please help.
    thank you
    Dev.

    Hi,
    The above screen shot is table where we maintain unpaid and paid breaks, we mention about when a break has to start under START tab and when it has to end under END button.
    Under UNPAID and PAID tabs we mention duration of break,  if its 15 mins break or half an hour or one hour depending on start and end timings.
    Suppose a shift is for 9 hours in total and client wants there should be a paid break of one hour, then out of this 9 hours shift itself  break would be considered.... and in case client wants unpaid break then shift would be for 10 hours out of which 9 hours will be working hours and one hour break.
    When this concept has to be calculated in schema processing type would be assigned to this time pair showing break accordingly either paid or unpaid.

  • XSLT Mapping Help Needed

    Hi,
    I have a XSD file with multiple references in my external definition. I am trying to build a schema validation functionality for a xml based on the multiple XSD's.
    Is it possible to do a schema validation using xslt mapping?
    I am using Altova mapforce to generate XSLT mapping but somehow it is not working. It gives me an error "XML Not well Formed".
    Please help!!

    Hi Jyanth
    yes you can do this
    i advice you to use XML Schema Tools like stylus studio or spy for editing, mapping, converting, validating, generating, binding and documenting any XML data model
    few  links for you how you can do in XML
    validating XML using XSLT
    http://www.ldodds.com/papers/schematron_xsltuk.html
    http://www.w3.org/TR/xslt20/
    http://www.stylusstudio.com/xsd_to_xsd.html
    https://www.xsltstudio.com/xml_schema.html
    regards
    Sandeep
    If helpful kindly reward points

  • XSLT Mapping - help

    Hi All,
    I am new to XSLT mapping.
    My requirement is: file to XML file with CDATA, for this I am planning to use the XSLT Mapping.
    I downloaded the Stylus studio, then what next, Please help meu2026
    In source flat file I have 5 fileds, and target I need to generate the XML file with CDATA set for 5 fields.
    Thanks,
    ANU-

    Hi Anu,
      Is your requirement is sending 5 fields into one string on target side ,If yes
      this code might help you for CDATA section
         <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
    <MT_TARGET>
    <String>
    <xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[?xml version=\"1.0\"
    encoding=\"ISO-8859-1\"?>]]]]></xsl:text>
    <xsl:copy-of select="*"/>
    <xsl:text disable-output-escaping="yes"><!CDATA[]]]></xsl:text>
    <xsl:text disable-output-escaping="yes"><![CDATA>]></xsl:text>
    </String>
    </MT_TARGET>
    </xsl:template>
    </xsl:Stylesheet>
    //if you use " * " then entire source structure will go into target StringUsers node
    Regards,
    Sandeep

  • Complex Mapping :-Help Required

    Hi All,
    I have a scenario XI--IDoc.
    Sender structure is having one field as Description which will carry some informatiom.I have to read the Summary Field and if I get XAA1:686,XAA2:767 or XAA3:876 like this  inside this  inside this field than I have substring  and take those value individually than we have to map it accordingly.
    You can consider all these value will come separated by ,(comma) and based of the sbustring we have to map it.
    Thanks,
    Rakhi

    1) Pattern p = Pattern.compile("\\b([X][A-Z]{2}[0-9][:][0-9]{3})\\b");
    we made a regular expression here and compiled it and then we make a object of class Matcher to match this compiled regex with our string
    Matcher m = p.matcher(str);
    //then we traverse through the results given to us my this matcher in an array form that is a array constituted by the different values that match this regex.....we traverse this array (m.find()) until this condition is true.....
    then we add the result into the display queue.
    while (m.find())
        String s = m.group(1);
        result.addValue(s);
    (\\b is actually \b to include this \(escape character) i had used two \\
    this is the real regex
    \b([X][A-Z]{2}[0-9][:][0-9]{3})\b
    \b means a seprator between words it can be anything tab or whitespace or new line
    () we use these brackets to mark a word or a unit here this XAA8:456 is a unit so we put the reg ex for this inside braces
    [X] single value mentioned means that it searches for only the single X character
    the very next [A-Z]{2} means that it searches for any character in range A-Z and this rule searches for combination of two letters that follow this rule it means that it searches for two characters together following this i.e adjacent like DF, GY if you think that you want to further drill down your pattern and you will always have AA you can replace this [A-Z]{2} by [A]{2} so it searches for XAA
    now the next thing should be a digit  so we have 0-9 if you dont specify {3} or any number in curly braces it assumes that you are searching for a single character
    then [0-9]{3} digits in the end.....
    use this site if you want to learn regex you can test your regex here
    http://regexr.com/#
    working on your next req

Maybe you are looking for

  • Can't get Apple Remote to work

    Please help - I received my new Apple TV yesterday and have been trying to set up but cannot get the remote to work. Whatever I press there is no response from the status light. I have tried Menu and right for 6 secs to pair -> nothing. I've tried Me

  • PI 7.1 JMS Adapter Correlation ID problem

    Hi, I try to get rid of the Correlation ID generated by the JMS Adapter (receiver). In the adapter configuration, processing tab, I choose Set Correlation ID To: NO VALUE. But still, in the message's details I can see a Correlation ID like this: 6265

  • Hyperlink in UI table column without using leadselect

    Hi All, I am using hyperlink for a column in my UI table element. When i click the hyperlink, I am opening a pop-up screen. The problem is, the pop-up is opening only after i leadselect a row and then i click the hyperlink. But i want the hyperlink c

  • Apple's Free Custom Ringtones

    I haven't seen this mentioned today in this forum but Apple quietly upgraded Garageband to allow the making of custom iPhone ringtones. It is now very easy to do and Garageband sports an icon for importing your custom ringtone (taken from just about

  • Get local server name at runtime

    Hi all, I am looking for a function module or a system parameter that can give me the current server name that my ABAP program runs on. I need to export the returned server name to parameter TARGETSERVER of function module 'JOB_CLOSE'. Thanks for you