# Conversion tables problem

Page 1 of 1

## 2 Replies - 1642 Views - Last Post: 20 June 2013 - 07:33 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=323348&amp;s=8cda682035610fe89e739754026b536f&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 amart904

• New D.I.C Head

Reputation: 0
• Posts: 1
• Joined: 20-June 13

# Conversion tables problem

Posted 20 June 2013 - 05:08 PM

hey guys, ive been working on this for hours we are supposed to write this in co

write a program that displays the following 2 tables side by side.(1 kilogram is 2.2 pounds)
ive done the code but cant figure out how to do the decimal spaces,, any help ?

Kilograms Pounds Pounds Kilograms
1 2.2 20 9.09
3 6.6 25 11.36

...
197 433.4 510 231.82
199 437.8 515 234.09

[quote name='amart904' date='20 June 2013 - 05:05 PM' timestamp='1371773101' post='1865023']
hey guys, ive been working on this for hours we are supposed to write this in co

write a program that displays the following 2 tables side by side.(1 kilogram is 2.2 pounds)
ive done the code but cant figure out how to do the decimal spaces,, any help ?

Kilograms Pounds Pounds Kilograms
1 2.2 20 9.09
3 6.6 25 11.36

...
197 433.4 510 231.82
199 437.8 515 234.09
```public class WeightConversionTables
{
public static void main(String[] args)
{
System.out.println(" | Kilo | Pounds | Pounds | Kilo");

for(int kilo = 1; pounds = 20; kilo <200; kilo += 2, pounds += 5)
{
int pounds = int(kilo* C * 10);
pounds =  int(Math.round(kilo);]

im sorry i dont know how to use this page but heres my code so far

public class WeightConversionTables
{
public static void main(String[] args)
{
System.out.println(" | Kilo | Pounds | Pounds | Kilo");

for(int i = 1, j = 1; i <= 200 && j <= 515; i+=2, j +=5 )
{
System.out.println(" | " + (i+1) + " | " + (i+1)*2.2 + " | "  + j + " | " + j/2.2 + " | " + j);
}
}
}

```

*Edited: please

This post has been edited by pbl: 20 June 2013 - 07:30 PM

Is This A Good Question/Topic? 0

## Replies To: Conversion tables problem

### #2 schutzzz

• D.I.C Regular

Reputation: 143
• Posts: 342
• Joined: 22-April 13

## Re: Conversion tables problem

Posted 20 June 2013 - 05:50 PM

It needs to be a Double for decimal places, not an Integer
Was This Post Helpful? 0

### #3 pbl

• There is nothing you can't do with a JTable

Reputation: 8378
• Posts: 31,956
• Joined: 06-March 08

## Re: Conversion tables problem

Posted 20 June 2013 - 07:33 PM

This does not make sense

```    for(int kilo = 1; pounds = 20; kilo <200; kilo += 2, pounds += 5)    {
int pounds = int(kilo* C * 10);
pounds =  int(Math.round(kilo);

```

you initialize pounds in your for() loop statement and do pounds +=5 in the same statement loop
but create a variable pounds inside the for() loop
Was This Post Helpful? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }