Welcome to Dream.In.Code
Become a Java Expert!

Join 150,194 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,056 people online right now. Registration is fast and FREE... Join Now!




System.out.println

 
Reply to this topicStart new topic

System.out.println, Java Dummy

didi2005
15 Sep, 2008 - 05:06 AM
Post #1

New D.I.C Head
*

Joined: 15 Sep, 2008
Posts: 24

Hi everyone. Im new to java. Currently i would like to create something like below.

IPB Image

But im having problem with the "system.out.println" syntax.
This is my code:

CODE
               
System.out.println("Payment\t    \t    \t Unpaid\t      Total Interest\t"); //Output of table listing
System.out.println("No.\t Interest\t Principal\t Balance\t To Date\t");
                               
for ( a = 1; a <= loan_period_month; a++){
   payment_no++;
   interest = (loan_amount * interest_rate / 100) / loan_period_month;
   System.out.println(""+payment_no);
}


For "System.out.println(""+payment_no);", how do i add other variable inside in order to display others values also?
I've tried "System.out.println("" +payment_no+ +interest+); , but error occur when compiled.

This post has been edited by didi2005: 15 Sep, 2008 - 05:22 AM
User is offlineProfile CardPM
+Quote Post

xerxes333
RE: System.out.println
15 Sep, 2008 - 05:20 AM
Post #2

D.I.C Head
Group Icon

Joined: 5 Jul, 2007
Posts: 223



Thanked: 11 times
Dream Kudos: 25
My Contributions
Try changing
CODE
  System.out.println(""+payment_no);

to
CODE
System.out.println("" + payment_no + "\t" + interest + "\t" + loan_amount + "\t" + unpaid + "\t" + interest_to_date);


(obviously replacing my variables with the actual variables)
User is offlineProfile CardPM
+Quote Post

didi2005
RE: System.out.println
15 Sep, 2008 - 05:37 AM
Post #3

New D.I.C Head
*

Joined: 15 Sep, 2008
Posts: 24

QUOTE(xerxes333 @ 15 Sep, 2008 - 06:20 AM) *

Try changing
CODE
  System.out.println(""+payment_no);

to
CODE
System.out.println("" + payment_no + "\t" + interest + "\t" + loan_amount + "\t" + unpaid + "\t" + interest_to_date);


(obviously replacing my variables with the actual variables)

Thx xerxes333

i changed it to "System.out.println("" + payment_no + "\t" + interest );" and is working.
User is offlineProfile CardPM
+Quote Post

Locke37
RE: System.out.println
15 Sep, 2008 - 06:52 AM
Post #4

Contributor of the Year
Group Icon

Joined: 20 Mar, 2008
Posts: 1,274



Thanked: 57 times
Dream Kudos: 325
My Contributions
As well it should. You only need one + sign per variable you're going to add.

Like you did with the null String and payment_no...there's only 1 + sign, right? tongue.gif smile.gif

Hope this helps you in the future! smile.gif

This post has been edited by Locke37: 15 Sep, 2008 - 06:53 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 04:29AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month