Int printing out as scientific notation

maybe doing something stupid here but I can't seem to pick it up.
I have a Window that calls a subclass to display a calculator, and then returns the final value to the Window, if I input 10 digits it prints on as a 12345678E5
something like that.
Anywho here's the two methods that deal with value in the subclass( calculator )
public int ReturnNumber(){//the method that will return the value from the keyboard
   int final_number = Integer.parseInt(number); 
    return final_number;   // returns value to question screen
  private void NextButtonActionPerformed (java.awt.event.ActionEvent evt) {
   if ( value.length() != allowable_answers[currentQuestionNumber] ){
                 JOptionPane.showMessageDialog(this, "Please make a valid entry.", "Invalid",
                 JOptionPane.WARNING_MESSAGE );
                 value.replace(0,counter,""); 
                 jTextField1.setText( null );
                 return;
    else {
            number = value.toString();
           setVisible(false);
           frame.final_number = ReturnNumber();
           frame.userMakeSelection = true;
           frame.FinalTimer.start();
           frame.ButtonSelected();Code from window that deals with the number
if(Numeric[currentQuestionNumber]){
            currentAnswers[currentQuestionNumber][1] = final_number;// currentAnswers is a float[][]
            numeric_question_value[currentQuestionNumber][0] = final_number;// used in poll frequency
          }// numeric is a int[]
        else
            currentAnswers[currentQuestionNumber][currentChoice] = currentChoice;Is from trying to jam an int into float?
Any suggestions
Jim

Is from trying to jam an int into float?That's exactly the cause. Here are some solutions:
- Use java.text.DecimalFormat to format the output or cast the float to an integer type when you want to print it (presicion might become a problem).
- Keep the number in an int or long all the time. This way you'll not lose any presicion.
Explanation can be found in the API docs of Float.toString():"If the argument is NaN, the result is the string "NaN".
Otherwise, the result is a string that represents the sign and magnitude (absolute value) of the argument. If the sign is negative, the first character of the result is '-' ('-'); if the sign is positive, no sign character appears in the result. As for the magnitude m:
If m is less than 10^-3 or not less than 10^7, then it is represented in so-called "computerized scientific notation." Let n be the unique integer such that 10n<=m<1; then let a be the mathematically exact quotient of m and 10n so that 1<a<10. The magnitude is then represented as the integer part of a, as a single decimal digit, followed by '.' (.), followed by decimal digits representing the fractional part of a, followed by the letter 'E' (E), followed by a representation of n as a decimal integer, as produced by the method Integer.toString(int) of one argument."

Similar Messages

  • How do you take a number out of scientific notation

    I have a number like 1.4353439E10 how do i make it say the actual number instead (1435343900).

    Could you change it's type to int? Maybe by casting?
    Best.
    SA

  • Decimal Format and Scientific Notation

    I am trying to print numbers in scientific notation using the Decimal Format class. What follows is a simple test program I wrote to find the bug. So far, I have not found a solution.
    import java.text.*;
    public class formatted {
    public static void main (String Arguments[]) {
    DecimalFormat form = new DecimalFormat("0.###E0");
         double numb = 123456.789;
         System.out.println("Nuber is: " +
    form.format(numb));
    The output of this program is... Nuber is: 123456E
    The output is the same if numb is an int, float, or double. If I format the number as "#####.0" or "#####.00" the output is correct. I think that I am following the rules for formatting a number in scientific notation as the process is outlined in the documentation (provided below).
    ***** From Decimal Format under Scientific Notation ***
    Numbers in scientific notation are expressed as the product of a mantissa and a power of ten, for
    example, 1234 can be expressed as 1.234 x 10^3. The mantissa is often in the range 1.0 <= x < 10.0,
    but it need not be. DecimalFormat can be instructed to format and parse scientific notation only via a
    pattern; there is currently no factory method that creates a scientific notation format. In a pattern,
    the exponent character immediately followed by one or more digit characters indicates scientific
    notation. Example: "0.###E0" formats the number 1234 as "1.234E3".
    Anyone understand how the short program is incorrectly written?
    Marc

    The problem is
    format = "0.###E0"
    input number = 123456.789
    output = 123456E (not scientific notation!)
    This is not scientific notation at all. There is no decimal point given and no value in the exponent.
    I understand entirely that by adding more #'es will provide more precision. The bug I have is the output is not printed in the scientific format; other formats work.
    MArc

  • Scientific Notation on MID

    having trouble with a
    parsed out excel file.
    We import processor files into our application and do so with maybe 20 different processors.
    However one file is giving us a particular problem, even though the MID colum looks to be  a simple MID like this
    8788840008835  it actually shows up once  extracted like this 8.78884000884E+012 scientific notarion
    this is the only file we have this problem with and even if we go in and reformat the colum in various ways so the column looks correct it still spits out this scientific notation.
    tried number format likwe this  #LSNumberFormat(objSheet.Query.column2, "______")#
    and like this #numberformat(objSheet.Query.column2,'_______________________')#   it that keeps the number from being in scientific notation however it rounds the MID on the last number to the closest zero effectivly ruining the data.
    Any ideas on how to get around this?
    BTW its not the initial extraction thats doing it, we use it on many other excel files with no problems, only this file is giving us this problem
    Thanks in advance for any help

    scrollin,
    Your digits are all there. Just format those cells to either Text or Number. Leading zeros do tend to get lost unless you pre-format to text. You can force the cell format to text on the fly by prefixing your input with a single-quote.
    Regards,
    Jerry

  • DecimalFormat issues/Scientific notation

    I have 2 issues with formatting numbers with scientific notation via the DecimalFormat class
    ISSUE 1: Disregard of the number of MAXIMUM FRACTOINAL DIGITS
         in the code:
                                     NumberFormat nf = NumberFormat.getInstance();
                                    DecimalFormat df = (DecimalFormat)nf;
                                    df.applyPattern("#00.#E0");
                                    System.out.println( df.format(12345678)); 
                                       it printed: 12.35E6
         Why does it violate my request for one significant digit beyond the decimal
         point?. (Note, this problem
    only seems to occur when when the sum of MAX integer and Max fractional
    digits in my pattern is 4)
    ISSUE 2:
    Number of significant digits displayed:- I really just need a sanity check on this one
    The 1.4.2 API for DecimalFormat states
    ?     The number of significant digits in the mantissa is the sum of the minimum integer and
    maximum fraction digits, and is unaffected by the maximum integer digits. For example,
    12345 formatted with "##0.##E0" is "12.3E3". To show all digits, set the significant digits
    count to zero. The number of significant digits does not affect parsing.
    I tried this ? it displays 123.45E3, or 5 significant digits? Looks like the number of significant digits
    is MAX integer + MAX fractional digits in a pattern. Am I correct (and the API not correct)?
    thanks
    carol

    Thanks. I'm assuming you're responding to issue #1. I did try it, and it worked, as expected. I never seem to have an issue when all symbols
    preceding the decimal are 0. My issue, I suppose, is the inconsistency of how the formatting
    works, when it comes to the number of fractional digit positions. Most of the times it 'behaves' and
    only prints out the number of digits you ask, but sometimes it does not.
    I've tested quite a few combinations. I'm attaching the code (in case you need help sleeping tonight).
    The only 'pattern' I've noticed is that this issue only occurs when the total number of digits specified
    in the pattern (before and after decimal) is 4. (exception ... if all digits specified before the decimal
    are 0s, this never occurs)
    I know a simple solution ... make sure I never have
    a total of 4 #s and 0s in my pattern. But again, my question is why ... and/or ... does this type of
    inconsistency crop up elsewhere.
    import java.util.*;
    import java.text.*;
    public class x {
         public static void main(String [] args) {
              NumberFormat nf = NumberFormat.getInstance();
              DecimalFormat df = (DecimalFormat)nf;
              // these 3 work like I'd expect: 3 digits to the left, one to the right w/ rounding
              // signif digits = max int digits + max fractional digits
              df.applyPattern("000.#E0");
              System.out.println( df.format(12345678)); // 123.5E5
              df.applyPattern("00.#E0");
              System.out.println( df.format(12345678)); // 12.3E6
              df.applyPattern("0.#E0");
              System.out.println( df.format(12345678)); // 1.2E7
              // signif digits = TOTAL int digits + max fractional digits
         System.out.println("X");
              df.applyPattern("###.#E0");                    // how did it decide to place decimal where it did?
              System.out.println( df.format(12345678)); // 12.35E6    // why did it violate my "1 max fractional digit"
                                                 // request? I would have expected 123.5E5
              df.applyPattern("##.#E0");
              System.out.println( df.format(12345678)); // 12.3E6
              df.applyPattern("#.#E0");
              System.out.println( df.format(12345678)); // 1.2E7
              //signif digits - TOTAL int digits + max fractional didgits
         System.out.println("");
         System.out.println("XXXXXXXX");
              df.applyPattern("#000.#E0");
              System.out.println( df.format(12345678));  // 1234.6E4
              df.applyPattern("#00.#E0");
              System.out.println( df.format(12345678));  // 12.35E6       // how did it decide to place decimal where it did?
                                                 // why did it violate my "1 max fractional digit"
                                                 // request? I would have expected 123.5E5
              df.applyPattern("#0.#E0");
              System.out.println( df.format(12345678)); //  12.3E6
              // significant digtis = TOTAL int digits + max fractional digits
         System.out.println("");
              df.applyPattern("###0.#E0");
              System.out.println( df.format(12345678));  // 1234.6E4
              df.applyPattern("##0.#E0");                    // how did it decide to place decimal where it did?
              System.out.println( df.format(12345678));  // 12.35E6     // why did it violate my "1 max fractional digit"
                                                 // request? I would have expected 123.5E5
              System.out.println( df.format(12345678));  // 12.35E6
              df.applyPattern("##.#E0");
              System.out.println( df.format(12345678));  // 12.3E6
    //API example from DecimaFormat RE Scientific Notation.. api says this will print 12.3E3
              df.applyPattern("###.##E0");
              System.out.println( df.format(12345)); //12.345E3   //violates max fractiona digit request
    //NOTE DOCS ARE WRONG ... the number of significant digits is = to max integer digits (number of # and 0 prior
    // to decimal point)  PLUS max number of digits after the decimal point... NOT Min. Integer digits + Max fractional digits
              // suggested pattern
              df.applyPattern("000000.##E0");
              System.out.println( df.format(12345678));  //123456.78

  • Scientific Notation to Integer?

    I have a string like 1.780657E7 that I need to convert to an integer. I think that might be too big for Integer, so maybe BigInt would be better.
    Anyway, I can't figure out how to do this! I guess I could write my own method, but I'm sure it's already out there somewhere. I'm pretty new to Java.
    Thanks a lot,
    - Andrew.

    A small exegesis of prometheuzz's perfectly accurate, if slightly terse solution.
    Scientific notation is assumed to be floating-point. You must therefore parse a scientific-notation string using Float.parseFloat() or Double.parseDouble() and "integerise" the result if an integer is what you want.
    The last line is to show that your sample number is easy to fit in an int variable.

  • Problem: program outputs numbers in scientific notation

    my problem is that my program outputs the population in scientific notation instead of round the number to the nearest one. ex: it should say 30787949.57 instead of 3.078794957 E7
    // Calculates the poulation of Mexico City from 1995 to 2018.
    // displays the year and population
    class PopulationCalculator {
    static double r2(double x) {
         //this method rounds a double value to two decimal places.
    double z=((double)(Math.round(x*100)))/100;
    return z;
    } //end method r2
    public static void main(String args[]) {
         double population=15600000.0;
         double rate=0.03;
         System.out.println("Mexico City Population, rate="+r2(rate));
         System.out.println("Year    Population");
         for (int year=1995; year<=2018;year++)  {
             System.out.println(year+ "    "+r2(population));
        population+=rate*population;
        }//end for loop
        System.out.println("The population of Mexico City reaches 30 million on 02/13/17 at 5:38:34am");
        }//end main
        }//end PopulationCalculator
    {code/]

A: problem: program outputs numbers in scientific notation

Or upgrade to JDK 5.0 and user the new java.util.Formatter capability.
You control the rounding and get localization of the fomatted string at
no extra charge. A quick example:
class A {
    public static void main(String[] args) {
        double d = 30787949.57d;
        System.out.println(java.lang.String.format("%,17.2f", d));
}Example output for three different locales:
$ javac -g A.java
$ LC_ALL=fr_FR   java A
    30 787 949,57
$ LC_ALL=en_NZ   java A
    30,787,949.57
$ LC_ALL=it_IT     java A
    30.787.949,57For more information, refer to:
http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#formatter

Or upgrade to JDK 5.0 and user the new java.util.Formatter capability.
You control the rounding and get localization of the fomatted string at
no extra charge. A quick example:
class A {
    public static void main(String[] args) {
        double d = 30787949.57d;
        System.out.println(java.lang.String.format("%,17.2f", d));
}Example output for three different locales:
$ javac -g A.java
$ LC_ALL=fr_FR   java A
    30 787 949,57
$ LC_ALL=en_NZ   java A
    30,787,949.57
$ LC_ALL=it_IT     java A
    30.787.949,57For more information, refer to:
http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#formatter

  • DecimalFormat bug (?) with scientific notation

    Hi there,
    i'm currently developing an application dealing with scientific notation of double values.
    When i was curious about forcing the DecimalFormat formatter to print an explicit sign character in the exponential part, i found this strange behaviour:
    Source code (example generated to show effect):
    import java.text.*;
    public class DecimalFormatBugTest {
    public static void main(String[] arguments) {
    DecimalFormat decimalFormat = new DecimalFormat("+0.00000E00");
    double testValue1 = 1.23456d;
    double testValue2 = 0.98765d;
    System.out.println("Test 1: " + testValue1 + " --> " + decimalFormat.format(testValue1));
    System.out.println("Test 2: " + testValue2 + " --> " + decimalFormat.format(testValue2));
    Output:
    Test 1: 1.23456 --> +1,23456E+00
    Test 2: 0.98765 --> +9,87650E-+01
    This is what i don't understand:
    The "workaround" with the explicit "+" in front of the whole format expression is already strange, but when the exponent turns negative, i have output like "E-+00" which is completly senseless.
    This output was generated using Java2 1.4.0 @ Win2k.
    Thanks for your comments!
    Greets, Marvin

    i have no clue why thats behaving that way but i can tell u another workaroun for doing what u want...
    I think u got to take that "+" sign off from the format u are giving while constructing the object DecimalFormat. Convert the result of decimalFormat.format(testValue1) into string and check for the character at 0. If its negative then prefix the result with '-' else with '+'.

  • Text code interpreted as scientific notation

    I have an http service returning xml to populate a data grid.
    The grid columns are tied to element attributes. One of these
    columns is a simple text code, like a product code. When this
    product code "looks like" scientific notation (e.g. "3E5"), the
    grid is displaying "300000" instead of the code. Is there a way
    somehow to tell the grid that this is a text field, and not a
    number? How do you turn this off? I am rendering the column with a
    label, but it doesn't make any difference. Thanks for any
    tips.

    Is from trying to jam an int into float?That's exactly the cause. Here are some solutions:
    - Use java.text.DecimalFormat to format the output or cast the float to an integer type when you want to print it (presicion might become a problem).
    - Keep the number in an int or long all the time. This way you'll not lose any presicion.
    Explanation can be found in the API docs of Float.toString():"If the argument is NaN, the result is the string "NaN".
    Otherwise, the result is a string that represents the sign and magnitude (absolute value) of the argument. If the sign is negative, the first character of the result is '-' ('-'); if the sign is positive, no sign character appears in the result. As for the magnitude m:
    If m is less than 10^-3 or not less than 10^7, then it is represented in so-called "computerized scientific notation." Let n be the unique integer such that 10n<=m<1; then let a be the mathematically exact quotient of m and 10n so that 1<a<10. The magnitude is then represented as the integer part of a, as a single decimal digit, followed by '.' (.), followed by decimal digits representing the fractional part of a, followed by the letter 'E' (E), followed by a representation of n as a decimal integer, as produced by the method Integer.toString(int) of one argument."

  • Infix to postfix printing out incorrectly sometimes..any ideas?

    alright, my program this time is to make an infix to postfix converter.
    I have it coded, and it works fine except when I use parenthesis. I'm supposed to test it with these expressions:
    a + b
    a * b + c
    a * ( b + c )
    a + b * c - d
    ( a + b ) * ( c - d )
    a - ( b - ( v - ( d - ( e - f ))))
         // initialize two stacks: operator and operand
         private Stack operatorStack = new Stack();
         private Stack operandStack = new Stack();
         // method converts infix expression to postfix notation
         public String toPostfix(String infix)
              StringTokenizer s = new StringTokenizer(infix);
              // divides the input into tokens for input
              String symbol, postfix = "";
              while (s.hasMoreTokens())
              // while there is input to be read
                   symbol = s.nextToken();
                   // if it's a number, add it to the string
                   if (Character.isDigit(symbol.charAt(0)))
                        postfix = postfix + " " + (Integer.parseInt(symbol));
                   else if (symbol.equals("("))
                   // push "("
                        Character operator = new Character('(');
                        operatorStack.push(operator);
                   else if (symbol.equals(")"))
                   // push everything back to "("
                        /** ERROR OCCURS HERE !!!! **/
                                 while (((Character)operatorStack.peek()).charValue() != '(')
                             postfix = postfix + " " + operatorStack.pop();
                        operatorStack.pop();
                   else
                   // print operatorStack occurring before it that have greater precedence
                        while (!operatorStack.isEmpty() && !(operatorStack.peek()).equals("(") && prec(symbol.charAt(0)) <= prec(((Character)operatorStack.peek()).charValue()))
                             postfix = postfix + " " + operatorStack.pop();
                        Character operator = new Character(symbol.charAt(0));
                        operatorStack.push(operator);
              while (!operatorStack.isEmpty())
                   postfix = postfix + " " + operatorStack.pop();
              return postfix;
    // method compares operators to establish precedence
         public int prec(char x)
              if (x == '+' || x == '-')
                   return 1;
              if (x == '*' || x == '/' || x == '%')
                   return 2;
              return 3;
    /** MY STACK **/
    import java.util.LinkedList;
    public class StackL {
      private LinkedList list = new LinkedList();
      public void push(Object v) {
        list.addFirst(v);
      public Object peek() {
        return list.getFirst();
      public Object pop() {
        return list.removeFirst();
      public boolean isEmpty()
          return (list.size() == 0);
    }weird, it erased my question/errors I put in...
    When I use any of the expressions with parenthesis (except the 2nd to last one) I get an emptystackexception pointing to the area noted in the code.
    When I test the 2nd to last one (the one I would expect it to give me the most trouble) it prints out an answer, but it is incorrect. It prints out this : "Expression in postfix: a ( b - ( c - ( d - ( e - f ) -" which is incorrect, as it hsould have no parenthesis
    Edited by: Taco_John on Apr 6, 2008 12:46 PM
    Edited by: Taco_John on Apr 6, 2008 12:47 PM
    Edited by: Taco_John on Apr 6, 2008 12:49 PM

    the algorithm we were told to use is here:
    While not stack error and not the end of infix expression
    a.) Extract the next input token from the infix expression (can be constant value, variable, arithmetic operator, left or right parenthesis)
    b.) If token is
    - left parenthesis : push it onto the stack
    - right parenthesis : pop and display stack elements until the left parenthesis is popped (don't sisplay right parenthesis). It's an error if stack becomes empty with no matching right parenthesis found.
    - Operator : if the stack is empty or token is higher priority than the top element, push it onto the stack. Otherwise, pop and display the top stack element and repeat comparison of token with new top element
    Note : left parenthesis in the stack is assumed to have a lower priority than any operator.
    - operand : display it
    When the end of the infix expression is reached, pop and display remaining stack elements until it is empty.
    it works fine on anything without a parenthesis, and it prints an answer (however it is incorrect) for the a - (b-(c-(d-(e-f)))) expression.
    still looking for an idea if I can get one
    Ok, I just noticed this. If i do a * ( b + c ) I get the error. But if I type " a * ( ( b + c ))" with spaces between the left parenthesis and adding an extra parenthesis as well, and NOT spacing the right parenthesis, I get a result that works just like that 2nd to last was doing. So it's something about the spaces...The answer is incorrect when I use the parenthesis as well. So it's not ignoring white space correctly for some reason and it's printing incorrect answers when I use parenthesis.

  • How t print out selected values from a Jlist

    hi iam trying to get the selected values from a list to print out as a string but iam getting ,Invalid cast from java.lang.Object[] to java.lang.String.is there any way to get the selected values t print ut as a string?? import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MultipleSelection2 extends JFrame {
    private JList colorList, copyList;
    private JButton copy;
    private String colorNames[] =
    { "Black", "Blue", "Cyan", "Dark Gray", "Gray",
    "Green", "Light Gray", "Magenta", "Orange", "Pink",
    "Red", "White", "Yellow" };
    public MultipleSelection2()
    super( "Multiple Selection Lists" );
    Container c = getContentPane();
    c.setLayout( new FlowLayout() );
    colorList = new JList( colorNames );
    colorList.setVisibleRowCount( 5 );
    colorList.setFixedCellHeight( 15 );
    colorList.setSelectionMode(
    ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
    c.add( new JScrollPane( colorList ) );
    // create copy button
    copy = new JButton( "Copy >>>" );
    copy.addActionListener(
    new ActionListener() {
    public void actionPerformed( ActionEvent e )
    // place selected values in copyList
    copyList.setListData(
    colorList.getSelectedValues());
    String s1 =(String)colorList.getSelectedValues();

    Since the JList method 'getSelectedValues' returns an object array you'll need to iterate through the array and cast each object in the array to a string as you access them.
    Object[] o = colorList.getSelectedValues();
    for(int count=0,end=o.length; count<end; count++) {
    String s = (String) o[count];
    Hope that helps
    Talden

  • SQL Server 2012 Management Studio:In the Database, how to print out or export the old 3 dbo Tables that were created manually and they have a relationship for 1 Parent table and 2 Child tables?How to handle this relationship in creating a new XML Schema?

    Hi all,
    Long time ago, I manually created a Database (APGriMMRP) and 3 Tables (dbo.Table_1_XYcoordinates, dbo.Table_2_Soil, and dbo.Table_3_Water) in my SQL Server 2012 Management Studio (SSMS2012). The dbo.Table_1_XYcoordinates has the following columns: file_id,
    Pt_ID, X, Y, Z, sample_id, Boring. The dbo.Table_2_Soil has the following columns: Boring, sample_date, sample_id, Unit, Arsenic, Chromium, Lead. The dbo.Table_3_Water has the following columns: Boring, sample_date, sample_id, Unit, Benzene, Ethylbenzene,
    Pyrene. The dbo.Table_1_XYcoordinates is a Parent Table. The dbo.Table_2_Soil and the dbo.Table_3_Water are 2 Child Tables. The sample_id is key link for the relationship between the Parent Table and the Child Tables.
    Problem #1) How can I print out or export these 3 dbo Tables?
    Problem #2) If I right-click on the dbo Table, I see "Start PowerShell" and click on it. I get the following error messages: Warning: Failed to load the 'SQLAS' extension: An exception occurred in SMO while trying to manage a service. 
    --> Failed to retrieve data for this request. --> Invalid class.  Warning: Could not obtain SQL Server Service information. An attemp to connect to WMI on 'NAB-WK-02657306' failed with the following error: An exception occurred in SMO while trying
    to manage a service. --> Failed to retrieve data for this request. --> Invalid class.  .... PS SQLSERVER:\SQL\NAB-WK-02657306\SQLEXPRESS\Databases\APGriMMRP\Table_1_XYcoordinates>   What causes this set of error messages? How can
    I get this problem fixed in my PC that is an end user of the Windows 7 LAN System? Note: I don't have the regular version of Microsoft Visual Studio 2012 in my PC. I just have the Microsoft 2012 Shell (Integrated) program in my PC.
    Problem #3: I plan to create an XML Schema Collection in the "APGriMMRP" database for the Parent Table and the Child Tables. How can I handle the relationship between the Parent Table and the Child Table in the XML Schema Collection?
    Problem #4: I plan to extract some results/data from the Parent Table and the Child Table by using XQuery. What kind of JOIN (Left or Right JOIN) should I use in the XQuerying?
    Please kindly help, answer my questions, and advise me how to resolve these 4 problems.
    Thanks in advance,
    Scott Chang    

    In the future, I would recommend you to post your questions one by one, and to the appropriate forum. Of your questions it is really only #3 that fits into this forum. (And that is the one I will not answer, because I have worked very little with XSD.)
    1) Not sure what you mean with "print" or "export", but when you right-click a database, you can select Tasks from the context menu and in this submenu you find "Export data".
    2) I don't know why you get that error, but any particular reason you want to run PowerShell?
    4) If you have tables, you query them with SQL, not XQuery. XQuery is when you query XML documents, but left and right joins are SQL things. There are no joins in XQuery.
    As for left/right join, notice that these two are equivalent:
    SELECT ...
    FROM   a LEFT JOIN b ON a.col = b.col
    SELECT ...
    FROM   b RIGHT JOIN a ON a.col = b.col
    But please never use RIGHT JOIN - it gives me a headache!
    There is nothing that says that you should use any of the other. In fact, if you are returning rows from parent and child, I would expect an inner join, unless you want to cater for parents without children.
    Here is an example where you can study the different join types and how they behave:
    CREATE TABLE apple (a int         NOT NULL PRIMARY KEY,
                        b varchar(23) NOT NULL)
    INSERT apple(a, b)
       VALUES(1, 'Granny Smith'),
             (2, 'Gloster'),
             (4, 'Ingrid-Marie'),
             (5, 'Milenga')
    CREATE TABLE orange(c int        NOT NULL PRIMARY KEY,
                        d varchar(23) NOT NULL)
    INSERT orange(c, d)
       VALUES(1, 'Agent'),
             (3, 'Netherlands'),
             (4, 'Revolution')
    SELECT a, b, c, d
    FROM   apple
    CROSS  JOIN orange
    SELECT a, b, c, d
    FROM   apple
    INNER  JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    LEFT   OUTER JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    RIGHT  OUTER JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    FULL OUTER JOIN orange ON apple.a = orange.c
    go
    DROP TABLE apple, orange
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How do I  print out the attributes of objects from a  Vector?  Help !

    Dear Java People,
    I have created a video store with a video class.I created a vector to hold the videos and put 3 objects in the vector.
    How do I print out the attributes of each object in the vector ?
    Below is the driver and Video class
    Thank you in advance
    Norman
    import java.util.*;
    public class TryVideo
    public static void main(String[] args)
    Vector videoVector = new Vector();
    Video storeVideo1 = new Video(1,"Soap Opera", 20);
    Video storeVideo2 = new Video(2,"Action Packed Movie",25);
    Video storeVideo3 = new Video(3,"Good Drama", 10);
    videoVector.add(storeVideo1);
    videoVector.add(storeVideo2);
    videoVector.add(storeVideo3);
    Iterator i = videoVector.interator();
    while(i.hasNext())
    System.out.println(getVideoName() + getVideoID() + getVideoQuantity());
    import java.util.*;
    public class Video
    public final static int RENT_PRICE = 3;
    public final static int PURCHASE_PRICE = 20;
    private int videoID;
    private String videoName;
    private int videoQuantity;
    public Video(int videoID, String videoName, int videoQuantity)
    this.videoID = videoID;
    this.videoName = videoName;
    this.videoQuantity = videoQuantity;
    public int getVideoID()
    return videoID;
    public String getVideoName()
    return videoName;
    public int getVideoQuantity()
    return videoQuantity;
    }

    Dear Bri81,
    Thank you for your reply.
    I tried the coding as you suggested
    while(i.hasNext())
    System.out.println( i.next() );
    but the error message reads:
    "CD.java": Error #: 354 : incompatible types; found: void, required: java.lang.String at line 35
    Your help is appreciated
    Norman
    import java.util.*;
    public class TryCD
       public static void main(String[] args)
         Vector cdVector = new Vector();
         CD cd_1 = new CD("Heavy Rapper", "Joe", true);
         CD cd_2 = new CD("Country Music", "Sam", true);
         CD cd_3 = new CD("Punk Music", "Mary", true);
         cdVector.add(cd_1);
         cdVector.add(cd_2);
         cdVector.add(cd_3);
         Iterator i = cdVector.iterator();
         while(i.hasNext())
           System.out.println( i.next() );
    public class CD
       private String item;
       private boolean borrowed = false;
       private String borrower = "";
       private int totalNumberOfItems;
       private int totalNumberOfItemsBorrowed;
       public CD(String item,String borrower, boolean borrowed)
         this.item = item;
         this.borrower = borrower;
         this.borrowed = borrowed;
       public String getItem()
         return item;
       public String getBorrower()
         return borrower;
       public boolean getBorrowed()
         return borrowed;
       public String toString()
          return System.out.println( getItem() + getBorrower());

  • How do I print out the value returned by a method in main??

    I'm a total newbie at java, I want to know how I can print out the value returned by this function in the "Main" part of my class:
    public int getTotalPrice(int price)
    int totalprice=price+(price*0.08);
    return totalprice;
    I just want to know how to print out the value for total price under "public static void main(String[] args)". thanks in advance,
    Brad

    Few ways you could do it, one way would be to create an instance of the class and call the method:
    public class Test
        public double getTotalPrice(int price)
            double totalprice = price + (price * 0.08);
            return totalprice;
        public static void main(String[] args)
            Test t = new Test();
            System.out.println(t.getTotalPrice(52));
    }Or another would be to make getTotalPrice() static and you could call it directly from main.

  • How can I print out an Array List in my GUI program?

    I have an ArrayList of Objects which I want to print out in a TextArea in my GUI. I tried using setText(), but it seems like that can only handle strings. Does anyone know of an alternative method or some other way to get around this?

    Ok, I have an object name Instrument which contains a double price, String name, int numberInStock. In my GUIFrame class which creates the GUI obviously, I have a button listener that should print out my ArrayList in a TextArea when clicked on a button.
    Here is the code:
    private class showIResponse implements ActionListener{
              public void actionPerformed(ActionEvent e){
                   showText.setText(parseString(ali));
    it is still giving me an error saying "cannot find symbol method parseString(java.util.ArrayList<java.lang.Object>)"

  • Maybe you are looking for

    • What is wrong with my macbook and is it worth fixing?

      I have a early 2008 white macbook. The last batch of the kind before the  unibody MBP came out. I have been  using my macbook for the past 5  years and it is still in great working condition with the exception of  the problem in the pics below.  The

    • Vendor Balance certification in CR

      Hi Experts, I want to develop the Vendor Balance due certificate as below. Note: If am giving range of Vendor Code From and To. It should develop the statement for all the vendor's in seperate page. A-ONE CARRIERS E-101, KAILASH ESPLANDE OPP.SHREYAS

    • External email suddenly not being received

      I have read through a bunch of these, but can't seem to find exactly what I have going on. The server consistently stops receiving email from outside the domain after about an hour of restarting it. I found that restarting the microsoft exchange tran

    • TS3989 new photos are not uploading to photostream

      i have a iphone 4s, ipad 2 and a MacPro using iPhoto.  Yesterday my devices stopped uploading NEW pictures to PhotoStream.  I've tested it by taking pictures with each device and waiting to see if it shows up in photostream.  Nothing works.  Is still

    • WLC Guest Access Randomly and Print

      Hi all, in my company have asked me a solution where automatically creates the guest account with username and password randomly. Is this solution possible to implement? With only the WLC?    p.s. you also know which models \ brands of printers allow