reset password
Author Message
ebayazi
Posts: 29
Posted 21:30 Feb 23, 2013 |

Hi guys;

This is what i got for this problem! Do you have any idea what we have to do to print just 4 digits (with decimal)?

Thank You :)

 

Attachments:
ZombieD
Posts: 14
Posted 23:01 Feb 23, 2013 |

You can use a "printf" statement, that's what I used to format my output. Take into account the total width of the table and also the width of each column and with that you can format it properly.

System.out.printf("/*Your formatting comes first inside the parenthesis*/", /*put variables here, and seperate each by commas*/);

zombiediaz91@gmail.com

Last edited by ZombieD at 23:03 Feb 23, 2013.
zkyaw
Posts: 1
Posted 23:01 Feb 23, 2013 |
  System.out.printf( "%4.1f",Variable_name );

%4.1f means... 4( represent for field width)  , 1( is for precision) and f ( vonversion code)

if you have textbook, look pave 113.

I hope that will work.

ebayazi
Posts: 29
Posted 23:17 Feb 23, 2013 |

Thank You :) yes I know about this but I'm not sure how to use this format in this problem?Should I use it inside Method or Main class?

kknaur
Posts: 540
Posted 11:27 Feb 24, 2013 |

Since your methods are returning values, you shouldn't use printf inside those conversion methods.  You would want to use it when you call your method from the main method.  If you can't figure out how to format the values using printf then don't worry about it.  The main objective here is to write two methods and then use a loop to print the table using calls of both methods.

ebayazi
Posts: 29
Posted 16:42 Feb 24, 2013 |

Thank You :) I tried it but couldn't figure it out! That would be great if we  go through this in class since we will need it later :)