Anyone can explain this program to me?

import java.util.List;
import java.util.LinkedList;
import java.util.Iterator;
public class Lab_02
     public static List getLinesOfText(int m)
{      List lines = new LinkedList();     
          StringBuffer line = new StringBuffer();
          for( int i = 0; i < m; i++ )
{         for( int j = 0; j < m; j++ )           
               line.append( j < i ? " ": Integer.toString(i%10) );
     lines.add(line.toString());
               line.setLength(0);
               return lines;
     public static void main(String args[])
     int n = 15;
               if( args.length > 0 )
               try
     {            n = Integer.parseInt(args[0]);
     catch( NumberFormatException nfe )
     {        String msg = nfe.getMessage();
          System.out.println(msg);
     Iterator lineIterator = getLinesOfText(n).iterator();
     while(lineIterator.hasNext())
          System.out.println(lineIterator.next());

  public static void main(String[] args) {
    int n = 15;
    if( args.length > 0 ) {                     // if an argument was entered
      try { n = Integer.parseInt(args[0]); }    // change it to an int
      catch( NumberFormatException nfe ) {      // if bad format
     String msg = nfe.getMessage();          // print a message
     System.out.println(msg);
//  call getLinesOfText(with the above number, it returns a List),
//  get an iterator for that list, and
//  assign that iterator to lineIterator
      Iterator lineIterator = getLinesOfText(n).iterator();
//  loop through the iterator printing each value
      while(lineIterator.hasNext()) System.out.println(lineIterator.next());
  public static List getLinesOfText(int m) {   // m = count from call above
    List lines = new LinkedList();             // make a LinkedList, assign to lines
    StringBuffer line = new StringBuffer();    // make a StringBuffer, assign to line
    for( int i = 0; i < m; i++ ) {             // loop m times
      for( int j = 0; j < m; j++ ) {           // for each value of i, loop m times
// append either a space or the string representation of i modulo 10
// to the StringBuffer depending on whether j is less that i
// (modulo = remainder after division by 10)
     line.append( j < i ? " ": Integer.toString(i%10) );
// Add the string representation of line (a StringBuffer) to the linkedlist lines
      lines.add(line.toString());
// Clear the StringBuffer
      line.setLength(0);
// return the linked list
    return lines;
  }

Similar Messages

  • Anyone can compile this program?Duke will be rewarded

    Anyone can help me compile this program..I try debugging a lot of time but it is not working!
    import java.lang.*;
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    public class ChatApplet extends Applet implements ActionListener,Runnable
    String user;
    String msg;
         public void init() {
              super.init();
              //{{INIT_CONTROLS
              setLayout(new BorderLayout(0,0));
              addNotify();
              resize(518,347);
              setBackground(new Color(12632256));
    msgbox = new java.awt.TextArea("",2,0,TextArea.SCROLLBARS_NONE);
              msgbox.setEditable(false);
    msgbox.disable();
    //msgbox.hide();
              msgbox.reshape(0,0,380,216);
              add(msgbox);
              idbox = new java.awt.TextField();
              idbox.reshape(84,288,284,24);
              add(idbox);
              button1 = new java.awt.Button("EnterRoom");
              button1.reshape(384,288,72,21);
              add(button1);
    list = new java.awt.List();
    //list.TOP_ALIGNMENT();
    //list.disable();
    list = new java.awt.List(5);
    list.add("#Default User"+"\n");
    list.reshape(384,24,128,196);
    list.setFont(new Font("Helvetica", Font.BOLD, 12));
    add(list);
              label2 = new java.awt.Label("Members");
              label2.reshape(396,0,100,19);
              add(label2);
              label1 = new java.awt.Label("UserName");
              label1.reshape(0,288,72,27);
              add(label1);
              textbox = new java.awt.TextField();
              textbox.reshape(84,240,431,44);
              add(textbox);
              label3 = new java.awt.Label("EnterText");
              label3.reshape(0,252,72,25);
              add(label3);
    //uf = new UserFrame();
              button1.addActionListener(this);
    idbox.addActionListener(this);
    textbox.addActionListener(this);
    list.addActionListener(this);
    public void actionPerformed(ActionEvent ae)
              if(ae.getSource()==idbox)
    user = idbox.getText()+"\n";
    list.addItem(user.trim());
    idbox.setText("");
                             msgbox.append(user+" HAS JOINED THE GROUP");
         if(ae.getSource().equals(button1))
    user = idbox.getText()+"\n";
    list.addItem(user.trim());
    idbox.setText("");
                             msgbox.append(user+" HAS JOINED THE GROUP");
    if(ae.getSource().equals(textbox))
    msg = textbox.getText();
    msgbox.append(msg+"\n");
    textbox.setText("");
    if(ae.getSource().equals(list))
    String l = list.getSelectedItem();
                             //uf.setTitle(l);
                             //Frame i[] = uf.getFrames();
                             //uf.setVisible(true);
    public void start()
    if(vt == null)
    vt = new Thread(this,getClass().getName());
    vt.start();
    public void run()
    try{
    for(int i=0;i<10;i++)
    msgbox.append("One stop Java source code - www.globalleafs.com"+"\n");
    msgbox.setForeground(Color.red);
    vt.sleep(30000);
    vt.resume();
    }catch(Exception e){e.printStackTrace();}
         java.awt.TextArea msgbox;
         java.awt.TextField idbox;
         java.awt.Button button1;
    java.awt.List list;
    java.awt.Label label2;
         java.awt.Label label1;
         java.awt.TextField textbox;
         java.awt.Label label3;
    private Thread vt;

    The program compiles over here. It just has some deprecation warnings ...or is that what you wanted debugged?
    Don't use reshape() ...I think in AWT you should now use setBounds();
    Don't use list.addItem(); ...looks like the API steers us to list.add();
    Don't use Thread.resume() ...I don't think there is a replacement (unneccessary?).
    Gee, this program must have ran the chat program in Ford's old model T ... !! (??)

  • Help,Could anyone can explain this to me ?

    public class A {
    B b;
         private int a;
         * @param args
         public int get(){
              return this.a;
         public static void main(String[] args) {
    class B{
         private int b;
         A a;
         public int get(){
              return this.b;
    There is a reference to A in Class B,and There is a reference to B
    in Class A,I am confused about this,could someone explain it to me ?

    learnningboy wrote:
    There is a reference to A in Class B,and There is a reference to B
    in Class A,I am confused about this,could someone explain it to me ?For example, there's a road between city X and city Y that goes two ways (you can travel from X to Y and you can also travel from Y to X). That's the idea: both cities hold a reference of each other in them.

  • Can anyone please explain this code to me?

    I am a new (junior)programmer?Can anyone please explain this code to me in lame terms? I am working at a client location and found this code in a project.
    _file name is AtccJndiTemplate.java_
    Why do we use the Context class?
    Why do we use the properties class?
    package org.atcc.common.utils;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.Properties;
    import java.util.logging.Logger;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import org.springframework.jndi.JndiTemplate;
    public class AtccJndiTemplate extends JndiTemplate
      private static Logger logger = Logger.getLogger(AtccJndiTemplate.class.getName());
      private String jndiProperties;
      protected Context createInitialContext()
        throws NamingException
        Context context = null;
        InputStream in = null;
        Properties env = new Properties();
        logger.info("Load JNDI properties from classpath file " + this.jndiProperties);
        try
          in = AtccJndiTemplate.class.getResourceAsStream(this.jndiProperties);
          env.load(in);
          in.close();
        catch (NullPointerException e) {
          logger.warning("Did not read JNDI properties file, using existing properties");
          env = System.getProperties();
        } catch (IOException e) {
          logger.warning("Caught IOException for file [" + this.jndiProperties + "]");
          throw new NamingException(e.getMessage());
        logger.config("ENV: java.naming.factory.initial = " + env.getProperty
    ("java.naming.factory.initial"));
        logger.config("ENV: java.naming.factory.url.pkgs = " + env.getProperty
    ("java.naming.factory.url.pkgs"));
        logger.info("ENV: java.naming.provider.url = " + env.getProperty
    ("java.naming.provider.url") + " timeout=" + env.getProperty("jnp.timeout"));
        context = new InitialContext(env);
        return context;
      public String getJndiProperties()
        return this.jndiProperties;
      public void setJndiProperties(String jndiProperties)
        this.jndiProperties = jndiProperties;
    }

    Hi,
    JNDI needs some property such as the
    java.naming.factory.initial
    java.naming.provider.url
    which are needed by the
    InitialContext(env);
    where env is a properties object
    Now if you can not find the physical property file on the class path
    by AtccJndiTemplate.class.getResourceAsStream(this.jndiProperties);
    where the String "jndiProperties" get injected by certain IOC ( inverse of control container ) such as Spring framework
    if not found then it will take the property from the system which will come from the evniromental variables which are set during the application start up i.e through the command line
    java -Djava.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory -Danother=value etc..
    I hope this could help
    Regards,
    Alan Mehio
    London,UK

  • I am new to oracle, plz..anybody can explain this query step by step....plz

    Select distinct(a.esal) from employee1 a where &N = (select count(distinct(b.esal)) from employee1 b where a.esal<=b.esal);
    this is the query to find Nth largest & Nth smallest value from the table employee1....but, i am unable to understand how this query works ....plz..anybody can explain this query step by step with example....plz

    Hi,
    Welcome to the forum!
    The first step in understanding any code is to format it so you can easily see what is a sub-query, what the major clauses of each sub-query are, and things like that.
    For example:
    Select distinct (a.esal)
    from   employee1      a
    where  &N     = (       select  count (distinct (b.esal))
                             from      employee1      b
                    where      a.esal           <= b.esal
                );The only thing I have added to the code you posted was whitespace: newlines, tabs and spaces.
    Now it's easy to see that you're doing a query with a scalar sub-query in the WHERE clause.
    It usually makes sense to read complicated queries from the inside out, that is, start with the deepest nested sub-query.
    In this example, that means:
    select  count (distinct (b.esal))
    from     employee1      b
    where     a.esal           <= b.esalWhat does this query do? Unfortunately, it references something (b.esal) from the super-query, so you can't run it by itself, to see what it does. Let's replace that reference with some hard-coded value, just for now, and run it:
    select  count (distinct (b.esal))
    from     employee1      b
    --where     a.esal           <= b.esal     -- This is the original WHERE clause
    where   a.esal           <= 1000     -- For testing only
    ;Experiment with this for a while, and compare it to the values in the employee1 table (or a small test table that resembles employee1). Try different numbers in place of 1000.
    You'll see that the query is counting how many different salaries are lower than, or equal to, a given salary (1000 in the example above).
    When you understand the sub-query, look at the original query again.
    It is testing to see if exactly &N different esals are lower than or equal to the esal on each row, and displaying that esal if it is. (&N is a substitution variable. If you haven't already defined a value for it, SQL*Plus will ask you for a value when you run the query.)
    In other words, it is finding the N-th lowest value of esal.

  • If anyone can check this file for me

    Hi!
    Trying to print this ai file I had created. I can't open it now in CS6, CC or 2014? Says I don't have enough memory. (RAM). It is only 1.6mb. I'm running win 7 x64.
    Here it is on dropbox if anyone can opening it and save it say in a standard PDF or more compatible format?
    AI FILE
    When placing it I get this:
    Thank you
    Max

    I can't open the file.
    1) Tells me not enough memory?
    2) placing it in latest PS or AI I get the screen?
    I'll start from scratch, but if the file is okay, I'd rather use that. So if anyone can check it for me. Thanks

  • Question on me51n: who can explain this phenomenon?

    Hi all,
    I am creating a Purchase Requisition via me51n.
    When I fill a 'K' or 'P' in the "acct assignment cat."(A) column in the Header Block. it will automatically bring me to the "Account Assignment" in the Item block, and give the "G/L account no" a default value 400000.
    I dont know why it give me the default value? can someone explain this to me, and where can I set up the configuration for the default value. I tried this in some other system, no such issues.
    Any response will be awarded.
    Thanks and regards,
    Samson

    hi,
    this is because an account modification key is maintained in your account assignemnet.
    please check the same in(OME9)
    say for example if VBR is maintained there check the sane in OBYC where correspondent to that account modification key same GL is maintained which it appears in your PR/PO
    VBR will be there in GBB Transaction key in OBYC
    Edited by: manipal on Dec 28, 2007 9:49 AM

  • Why can't this program access the private class

    All,
    If you could give me some help I would appreciate it, as I have been worrying this issue for some time now and cannot figure out why this program will not compile. It tells me that there are a number of errors, and it appears that these errors are due to the fact that it will not allow me to reach from the private class to the primary for variables. Now, I have seen another program that is very similar and it does not have these issues. IF someone would explain to me what is going on here I think that I could fix it. Thanks
       import java.io.*;
       import java.awt.*;
       import java.awt.event.*;
       import javax.swing.*;
       import java.text.*;
       import java.util.*;
       import java.lang.*;
        public class MortgageGUIv4_1 extends JFrame
           public static void main(String[] args)
             new MortgageGUIv4_1();
          double MP, calcAPR, APR, adjustAPR, annualAPR;
          double monthTerm, userTerm;
          double userPrin;
          boolean user = false;
          String headers = "Payment No. \t\tRemainging Balance \tInterest Paid";
          String []loanRates = {"7 years at 5.35%,15 years at 5.5, 30 years at 5.75%"};
           public MortgageGUIv4_1()
             ButtonListener b1 = new ButtonListener();
             JPanel firstRow = new JPanel();
             JPanel fourthRow = new JPanel();
             JPanel fifthRow = new JPanel();
             JPanel sixthRow = new JPanel();
             JPanel seventhRow = new JPanel();
             JPanel fieldPanel = new JPanel();
             JPanel buttonPanel = new JPanel();
             JPanel buttonPanel3 = new JPanel();
             JLabel userPrinLabel = new JLabel("Principle:  ");
             JTextField userPrinvalue = new JTextField(10);
             ButtonGroup loanGroup = new ButtonGroup();   
             JLabel outputLabel = new JLabel("Click to see your payment");
             JButton buttonSubmit = new JButton("Submit");
             buttonSubmit.addActionListener(b1);
             JLabel outputLabel3 = new JLabel("Click here to clear Data");
             JButton buttonClear = new JButton("Clear");
             buttonClear.addActionListener(b1);
             JLabel mortgagePayment = new JLabel ("Your Monthly Payments are");
             JTextField totPayment = new JTextField(10);
             JComboBox termRateBx = new JComboBox(loanRates);
             JLabel termRateLbl = new JLabel("Select a Term and Rate from the options listed");
             JTextArea pymntTable = new JTextArea(headers, 10, 50);
             JScrollPane scroll = new JScrollPane(pymntTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
             try
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
                 catch(Exception e)
                   JOptionPane.showMessageDialog(null,"The UIManager could not set the Look and Feel for this applicatoin.", "Error",
                      JOptionPane.INFORMATION_MESSAGE);
             MortgageGUIv4_1 winPane = new MortgageGUIv4_1();
             winPane.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             winPane.setSize(300,300);
             winPane.setTitle("Dan's Mortgage GUI System");
             winPane.setResizable(false);
             winPane.setLocation(200,100);
             winPane.setVisible(true);
             Container cont = getContentPane();
             cont.setLayout((new BorderLayout()));
             fieldPanel.setLayout(new GridLayout(8,1));
             FlowLayout rowSetup = new FlowLayout(FlowLayout.CENTER, 5,3);
             firstRow.setLayout(rowSetup);
             fourthRow.setLayout(rowSetup);
             fifthRow.setLayout(rowSetup);
             sixthRow.setLayout(rowSetup);
             seventhRow.setLayout(rowSetup);
             buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
             buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
             firstRow.add(userPrinLabel);
             firstRow.add(userPrinvalue);
             fourthRow.add(mortgagePayment);
             fourthRow.add(totPayment);
             fifthRow.add(termRateBx);
             fifthRow.add(termRateLbl);
             sixthRow.add(scroll);
             fieldPanel.add(firstRow);
             fieldPanel.add(fourthRow);
             fieldPanel.add(fifthRow);
             fieldPanel.add(sixthRow);
             fieldPanel.add(seventhRow);
             buttonPanel.add(buttonSubmit);
             buttonPanel.add(buttonClear);
             cont.add(fieldPanel, BorderLayout.CENTER);
             cont.add(buttonPanel, BorderLayout.SOUTH);
           private class ButtonListener implements ActionListener
              public void actionPerformed(ActionEvent e)
                Object source = e.getSource();
             //used the term user because this is the user input.  When the user inputs a correct value then the program moves on
                do
                   //captures the user data entered in the text field and converts it to double
                   String enterAmount = userPrinvalue.getText();
                   userPrin = Double.parseDouble(enterAmount);
                   if(userPrin <0)
                      JOptionPane.showMessageDialog(null,"The Principle value is out of range.  Please choose a value that is greater than 0", "Error",
                         JOptionPane.INFORMATION_MESSAGE);
                   else user=true;
                }while (!user);
                if(source == buttonSubmit)
                //captures the user data entered in the text field and converts it to double
                   String enterAmount = userPrinvalue.getText();
                   userPrin = Double.parseDouble(enterAmount);
                   if(selection.equals(loanRates[0]))
                      APR = 535 / (12 * 100);  //The APR is converted from whole number to % and reduced to the monthly rate
                      monthTerm = 7 * 12;  //The Term must be converted to months
                      adjustAPR= 1 + APR;
                      calcAPR = 1 - Math.pow(adjustAPR, -monthTerm);
                   if(selection.equals(loanRates[1]))
                      APR = 550 / (12 * 100);  //The APR is converted from whole number to % and reduced to the monthly rate
                      monthTerm = 15 * 12;  //The Term must be converted to months
                      adjustAPR= 1 + APR;
                      calcAPR = 1 - Math.pow(adjustAPR, -monthTerm);
                   if(selection.equals(loanRates[2]))
                      APR = 575 / (12 * 100);  //The APR is converted from whole number to % and reduced to the monthly rate
                      monthTerm = 30 * 12;  //The Term must be converted to months
                      adjustAPR= 1 + APR;
                      calcAPR = 1 - Math.pow(adjustAPR, -monthTerm);
                   MP = userPrin * (APR / calcAPR);
                   DecimalFormat twodigits = new DecimalFormat("#,###.##");
                //The system will now render the monthly payment amount
                   totPayment.setText("$" + twodigits.format(MP));
                   double loanBal, newLoanBal, mnthlyIntPd, mnthlyPrinPd;
                   for (int i = 0; i >= monthTerm;i++)
                      newLoanBal = loanBal;
                      mnthlyIntPd = loanBal * APR;
                      mnthlyPrinPd = MP - mnthlyIntPd;
                      loanBal = loanBal - mnthlyPrinPd;
                      pymntTable.append("\n"+i+ "\t\t" + twodigits.format(loanBal)+ "\t\t" + twodigits.format(mnthlyIntPd));
                if(source == buttonClear)
                   userPrinvalue.setText("");
                   pymntTable.setText(headers);
       }Dan

    Thank you one and all, in part to what you said here I when through and obviously had to make some serious changes to the code. Now it will compile however, when I try to run it I am getting the following error. do not use MortgageGUIv4_1.add() use MortgageGUIv4.1.getContentPane.add instead. I am at a loss for this one, as when I looked it up the only difference was that the one is awt and the other is swing. Could someone please let me know what I am missing.
    Thanks
    Dan
       import java.io.*;
       import java.awt.*;
       import java.awt.event.*;
       import javax.swing.*;
       import javax.swing.event.*;
       import javax.swing.border.*;
       import java.text.*;
       import java.util.*;
       import java.lang.*;
        public class MortgageGUIv4_1 extends JFrame
           public static void main(String[] args)
             new MortgageGUIv4_1();
          double MP, calcAPR, APR, adjustAPR, annualAPR;
          double monthTerm, userTerm;
          double userPrin;
          boolean user = false;
          String headers = "Payment No. \t\tRemainging Balance \tInterest Paid";
          String loanRates[] = {"7 years at 5.35%","15 years at 5.5", "30 years at 5.75%"};
              private JLabel userPrinLabel, outputLabel, outputLabel3, mortgagePayment, termRateLbl;
              private JTextField userPrinvalue, totPayment;
              private JButton buttonClear, buttonSubmit;
              private JComboBox termRateBx = new JComboBox(loanRates);
              private JTextArea pymntTable;
              private JScrollPane scroll = new JScrollPane(pymntTable);
           public MortgageGUIv4_1()
             ButtonListener b1 = new ButtonListener();
               this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             this.setSize(900,500);
             this.setTitle("Dan's Mortgage GUI System");
             this.setLocation(240,0);
             this.setVisible(true);
             JPanel winPane = new JPanel();
             JPanel userPrinciple = new JPanel();
             userPrinLabel = new JLabel("Principle:  ");
             userPrinvalue = new JTextField(10);
             userPrinciple.add(userPrinLabel);
             userPrinciple.add(userPrinvalue);
             ButtonGroup loanGroup = new ButtonGroup();
             outputLabel = new JLabel("Click to see your payment");
             buttonSubmit = new JButton("Submit");
             buttonSubmit.addActionListener(b1);
             outputLabel3 = new JLabel("Click here to clear Data");
             buttonClear = new JButton("Clear");
             buttonClear.addActionListener(b1);
               JPanel results = new JPanel();
               mortgagePayment = new JLabel ("Your Monthly Payments are");
             totPayment = new JTextField(10);
               results.add(mortgagePayment);
             results.add(totPayment);
               JPanel comboBx = new JPanel();
             termRateLbl = new JLabel("Select a Term and Rate from the options listed");
               comboBx.add(termRateBx);
             comboBx.add(termRateLbl);
             pymntTable = new JTextArea(headers, 10, 50);
             JScrollPane scroll = new JScrollPane(pymntTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
             try
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
                 catch(Exception e)
                   JOptionPane.showMessageDialog(null,"The UIManager could not set the Look and Feel for this applicatoin.", "Error",
                      JOptionPane.INFORMATION_MESSAGE);
             winPane.add(userPrinciple);
             winPane.add(comboBx);
             winPane.add(results);
               winPane.add(scroll);
               winPane.add(outputLabel);
               winPane.add(buttonSubmit);
             winPane.add(outputLabel3);
             winPane.add(buttonClear);
               this.add(winPane);
           private class ButtonListener implements ActionListener
              public void actionPerformed(ActionEvent e)
                Object source = e.getSource();
                String selection = (String)termRateBx.getSelectedItem();
             //used the term user because this is the user input.  When the user inputs a correct value then the program moves on
                do
                   //captures the user data entered in the text field and converts it to double
                   String enterAmount = userPrinvalue.getText();
                   userPrin = Double.parseDouble(enterAmount);
                   if(userPrin <0)
                      JOptionPane.showMessageDialog(null,"The Principle value is out of range.  Please choose a value that is greater than 0", "Error",
                         JOptionPane.INFORMATION_MESSAGE);
                   else user=true;
                }while (!user);
                if(source == buttonSubmit)
                //captures the user data entered in the text field and converts it to double
                   String enterAmount = userPrinvalue.getText();
                   userPrin = Double.parseDouble(enterAmount);
                   if(selection.equals(loanRates[0]))
                      APR = 535 / (12 * 100);  //The APR is converted from whole number to % and reduced to the monthly rate
                      monthTerm = 7 * 12;  //The Term must be converted to months
                      adjustAPR= 1 + APR;
                      calcAPR = 1 - Math.pow(adjustAPR, -monthTerm);
                   if(selection.equals(loanRates[1]))
                      APR = 550 / (12 * 100);  //The APR is converted from whole number to % and reduced to the monthly rate
                      monthTerm = 15 * 12;  //The Term must be converted to months
                      adjustAPR= 1 + APR;
                      calcAPR = 1 - Math.pow(adjustAPR, -monthTerm);
                   if(selection.equals(loanRates[2]))
                      APR = 575 / (12 * 100);  //The APR is converted from whole number to % and reduced to the monthly rate
                      monthTerm = 30 * 12;  //The Term must be converted to months
                      adjustAPR= 1 + APR;
                      calcAPR = 1 - Math.pow(adjustAPR, -monthTerm);
                   MP = userPrin * (APR / calcAPR);
                   DecimalFormat twodigits = new DecimalFormat("#,###.##");
                //The system will now render the monthly payment amount
                   totPayment.setText("$" + twodigits.format(MP));
                   double loanBal = userPrin, newLoanBal, mnthlyIntPd, mnthlyPrinPd;
                   for (int i = 0; i >= monthTerm;i++)
                      newLoanBal = loanBal;
                      mnthlyIntPd = loanBal * APR;
                      mnthlyPrinPd = MP - mnthlyIntPd;
                      loanBal = loanBal - mnthlyPrinPd;
                      pymntTable.append("\n"+i+ "\t\t" + twodigits.format(loanBal)+ "\t\t" + twodigits.format(mnthlyIntPd));
                if(source == buttonClear)
                   userPrinvalue.setText("");
                   pymntTable.setText(headers);
       }

  • Strange: blank in string. Anybody can explain this?

    Hello!
    Look at this. Until now I thougt, I had understood ABAP...
    Output of the following programm:
    1) Strange
    2) Strange
    3) Strange
    4) Strange
    5) Strange
    6) Strange
    Very strange, isn't it?
    ABAPDOCU tells, that strings pay attention to blanks.
    Can anybody explain this?
    REPORT zstrange.
    DATA: stringwithspace TYPE string VALUE 'A B',
          teststring TYPE string,
          blankstring TYPE string VALUE ' ',
          l type i.
    START-OF-SELECTION.
      IF stringwithspace+1(1) = ' '.
        WRITE: / '1) My guess'.
      ELSE.
        WRITE: / '1) Strange'.
      ENDIF.
      IF stringwithspace+1(1) = blankstring.
        WRITE: / '2) guess'.
      ELSE.
        WRITE: / '2) Strange'.
      ENDIF.
      IF stringwithspace+1(1) = ''.
        WRITE: / '3) guess'.
      ELSE.
        WRITE: / '3) Strange'.
      ENDIF.
      teststring = stringwithspace+1(1).
      IF teststring = ' '.
        WRITE: / '4) Guess'.
      ELSE.
        WRITE: / '4) Strange'.
      ENDIF.
      IF teststring = blankstring.
        WRITE: / '5) Guess'.
      ELSE.
        WRITE: / '5) Strange'.
      ENDIF.
      IF teststring = ''.
        WRITE: / '6) guess'.
      ELSE.
        WRITE: / '6) Strange'.
      ENDIF.

    No, thats not strange.
    c variables have always a fixed length, it can not contain "nothing". If there are only spaces in, the c variable is treated as empty/initial.
    Strings can contain nothing, and they can contain spaces. A string containing blanks is not interpreted as empty/initial.
          blankstring TYPE string VALUE ' ',
    What you are doing here is assigning an empty string to the string var blankstring, it does NOT contain a blank.
    Constants encapsulated with apostrophes are treated as c variables. But: constants encapsulated within back quotes will be interpreted as string. Change your code to
          blankstring TYPE string VALUE ` `,
    Take care of that i used back quotes now, not apostrophes, Now the var blankstring contains a blank and the result in that case will change to MY guess.
    Similar the camparison
      IF stringwithspace+1(1) = ' '.
    This is comparing a blank with an empty char and thats why you are getting strange.
    Change this to
      IF stringwithspace+1(1) = ` `.
    and you will get My guess cause now you are comparing a blank with a blank and not a blank with an empty string.
    Hope its now clear.

  • HT1414 I am going through the process of unlocking my iphone 4 and have had all the go aheads from my service provider but i am still having problems when i plug the phone into itunes. Has anyone else had this program

    I am going through the process of unlocking my iphone 4 and have had all the go aheads from my service provider but i am still having problems when i plug the phone into itunes. Has anyone else had this problem??

    Umm, what problem?  What actually happens when you try to restore it in iTunes?

  • Can anyone help explain this reoccurring sys log?

    I've tried to track down this event that keeps on repeating so much its making my system log reach almost 60mb! Below is a copy of the log...
    Jun 21 07:14:15 localhost kernel: USBF: 16123.117 IOUSBInterface[0x2fadb00]::handleOpen failing because super::handleOpen failed (someone already has it open)
    ...Do I have some USB device bummin out my system? Such as a USB hub causing a conflict or something? If anyone knows how I can possibly cure or even track down the cause of this reoccurring event, that would be awesome!
    MUCHO THANKS!
    PowerMac G4 1.25GHZ   Mac OS X (10.3.9)  

    R.E.BELL...
    First of all how long has it been that you ran any type of a utility that clears out your System Logs? Yasu (outside link) is my favorite and well named. Tip is to never let your logs get into that 60MB condition.
    As far as the error goes, unless it is choking on it or something isn't working, I would say it is a benign, harmless, or oops! kind of an error.
    ...Ron

  • Can anyone please explain this double problem?

    public class DoTest {
         static int i;
         public static void main(String[] args){
              double a = 3.0;
              double b = 0.3;
              double c = 0.3;
              double d = 0.3;
              System.out.println(c+a+b);
              System.out.println(d+c);
    }Result:
    3.5999999999999996
    0.6
    Why does the first println statement return 3.5999999999999996?
    Cheers

    import java.text.DecimalFormat;
    public class DoTest {
         static int i;
         public static void main(String[] args){
              double a = 3.0;
              double b = 0.3;
              double c = 0.3;
              double d = 0.3;
              double f=c+a+b;
              DecimalFormat df=new DecimalFormat("#.##");
              System.out.println(df.format(f));
              System.out.println(d+c);
    this is enougn for u man..
    do sme experiment wit it

  • Can anyone please explain this message

    Mac OS X Version 10.4.11 (Build 8S2167)
    2007-12-17 07:27:53 -0500
    2007-12-17 07:27:54.749 HPEventHandler[234]: DebugAssert: Third Party Client: (NULL != m_lock && 0 == errno) Can't create semaphore lock[/Volumes/Development/HP/Mac-Sirani/mac-software/components/HPEventHandler/ Sources/Core/HPTMNotificationManager.cpp:62]
    2007-12-17 07:28:12.455 Translator[275] Invoked to sync conduit com.apple.Safari for entityNames: com.apple.bookmarks.Folder,com.apple.bookmarks.Bookmark
    Waiting for MirrorAgent to launch and respond to CFMessagePortCreateRemote().

    Try reimporting all your media: file>>import>>reimport>>continue

  • Can Anyone Help Explain this to me?

    When you go to your usage, under lifetime (after a full charge) it will say 2 hours... I don't really know what "lifetime" means, but I would think that's the time the battery will last... Am I wrong in assuming this, and if i'm right isn't 2 hours rather low for a fully charged battery?
    Also, my usage is showing 1 hour 47 minutes... I've barely touched my phone all day... what's the deal?

    Well the usage that we were referring to in the original post is under Settings>>Usage, but I think you are referring to something different...
    Maybe they are guess-timating the percentage by how much green they are seeing on their battery (i.e. 50% is half bar)

  • I have an ipad and have a 'GOOD' app which i think i have to have to download my purchased i tunes. But it wont open in good becasue i need a password/account - can anyone help explain this, and how to access my itunes

    In the past i set up a KNOWCLOUD on a computer which is now defunct.  So, i have all my photos and a few itunes stuck in the scam KNOWCLOUD and have now purchased an ipad and i phone.  When i try to down load my photos it says save to GOOD, but when i open good it says i need to contact my administrator for password and username.  Any suggestions ?

    I have the same problem , i've converted my videos to mp4 , by using different programmes and tried to open them in itunes but it didnt .
    Some people suggested the following although it didnt help me , it might help you
    One suggested to paste the videos that you want in automatically add to itune (  go to your music folder m then click on itunes , then itunes media , and you will find it there )
    Others suggested to o to the ontrol panal , then programmes and features m then lick on quick time (. Or itunes) then Change then repair
    If it didnt help. And you find another method m please let me know
    Thank you

Maybe you are looking for

  • Since upgrading I can no longer update software from the apps store.

    Since upgrading to Mountain Lion the apps store keeps telling me that I have software to update. It starts doing it then fails. Its done this about three times now. Any suggestions? Thanks Chris

  • Will Mac mini 2.3Ghz i7 resolution fit on a monitor with 16:10(22inch) or 16:9(27inch)?

    I am starting to use a Mac mini for the first time and needing to buy a monitor for it. I am thinking of a 22inch or a 27 inch. Third party monitors though. Can't afford apple Cinema Display (27"). Will a 16:10 or a 16:9 fit for Mac mini's display? I

  • Urgent: Please help! Struts in portal

    I put struts-config.xml under beaApps\portalApp\mywebApp\WEB-INF. But it seems not seen by the system. Somebody has done this before, please advise me how to integrate struts into bea portal 7.0 I am waiting for your response here! Thanks a lot!!!!!!

  • Upgrading to OS X 10.10 Yosemite

    Hi all, I would like to upgrade from Mavericks to Yosemite (I currently run 10.9). I would like to upgrade to 10.10 or 10.10.1, BUT NOT to 10.10.2 as my Pro Tools software doesn't support it. The issue is that when trying to upgrade, the only version

  • Goods Receipt for scheduling agreements

    Dear Experts,   I have created schedule lines through MRP in MD03. But when i tried to do  goods receipt for that scheduling agreement , it is telling "Document xxxxxxxxxxx does not contain any items ". I am doing GRN w.r.to that scheduling agreement