Displaying data in table with java? - KingPin's Forum
KPsDenKPsDen ArmoryImage HostingLegendz text RPGIp DisplayIRCFlash Arcade
Forum
      |        
Register
         [epic] post you pic thread [/epic] (Posted By:wout - Replies:325 - Views:7763)      « »     Double dragon (Posted By:Bionuclear - Replies:2 - Views:33)      « »     One more vote for Staff (Posted By:Bionuclear - Replies:8 - Views:46)      « »     .trade in Reputation Item list (Posted By:djinnking - Replies:20 - Views:460)      « »     [Check4SPAM] RE: Top 10 Most Popular iPod Video Tools (Posted By:Jasony - Replies:0 - Views:1)      « »     [Check4SPAM] RE: Top 10 Most Popular iPod Video Tools (Posted By:Jasony - Replies:0 - Views:1)      « »     [Check4SPAM] RE: Top 10 Most Popular iPod Video Tools (Posted By:Jasony - Replies:0 - Views:1)      « »     [Check4SPAM] RE: Top 10 Most Popular iPod Video Tools (Posted By:Jasony - Replies:0 - Views:1)      « »     FINAL Standardized Ghq Prices (Posted By:gombie - Replies:11 - Views:810)      « »     tker (Posted By:Texan - Replies:1 - Views:11)      « »     
KingPin's Forum
 
K.P.s.N. Register vbBux / KPs Mall Bugs Blogs FAQ Search Today's Posts Mark Forums Read Donate
Go Back   KingPin's Forum > KP's Network Forum > RSS News
Reload this Page Displaying data in table with java?
 


RSS News This is a discussion on Displaying data in table with java? in the RSS News;
Description: I am developing a program where the user enters a starting integer and an ending integer then in a table ...

Reply
 
LinkBack Thread Tools
Displaying data in table with java?
(#1 (permalink))
Old
iverson_575 is Offline
Private
Points: 196, Level: 2 Points: 196, Level: 2 Points: 196, Level: 2
Activity: 0% Activity: 0% Activity: 0%
iverson_575 is an unknown quantity at this point
 
iverson_575
Rupees: 156.20
Bank: 500.00
Total Rupees: 656.20
 
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Dec 2007
Displaying data in table with java? - December 13th, 2007

I am developing a program where the user enters a starting integer and an ending integer then in a table I print the staring integer to the ending integer sqrt(), cbrt(), exp().
Should look something like this:

say i enter 1 and 5

Square root: 1 2 4 5
Cube root: 6 8 9 0
exp: 7 8 9 0


doubles have to be formated to 2 decimal places. Heres what I have so far. I just don't know how to show Sqare Root, Cube Root, and exp only once with out repeating witht the number the user entered.

while(s <= e)
{
System.out.print("Squre Root "+form.format(Math.sqrt(s)));
System.out.print("Cube Root "+form.format(Math.cbrt(s)));
System.out.print("Exp "+form.format(Math.exp(s)));
s++;
}

I end up getting something like this:

Square Root: 1.00 Square Root 1.41 Square Root 1.73
Cube Root: 3.00 Cube Root 6.34 Cube Root 4.56
Exp: 4.32 Exp: 2.34 Exp: 1.23

 
Reply With Quote
Revenue Shared Ads
(#2 (permalink))
Old
Whatever is Offline
Private
Points: 193, Level: 2 Points: 193, Level: 2 Points: 193, Level: 2
Activity: 0% Activity: 0% Activity: 0%
Whatever is an unknown quantity at this point
 
Whatever
Rupees: 3.30
Bank: 500.00
Total Rupees: 503.30
 
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Dec 2007
December 13th, 2007

You could just have one loop for each operation, like so:

// print one line with Square Roots
System.out.print ("Square Root") ;
for (int i = s; i <= e; i++)
{
System.out.print (form.format (Math.sqrt(s)));
}
System.out.print("\n");

// Print one line with Cube Roots
System.out.print ("Cube Root");
for (int i = s; i < e; i++)
System.out.print... and so forth

It isn't very pretty, but it gets the job done. Mind you, form.format isn't standard Java, and I have no idea how it works, I just copied it from your code.

 
Reply With Quote
Revenue Shared Ads
Reply

Bookmarks

Tags
data, displaying, java, table

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Rupees Per Thread View: 1.00
Rupees Per Thread: 15.00
Rupees Per Post: 5.00
Forum Jump



Powered by vBulletin® Version 3.8.0 Beta 1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright 2004-2009 KPsN


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81