Michael Mikhail

Greenhorn

Posts: 5

posted 5 years ago

Hi guys. I`m new to java, well actually to programing and i`m tryin to solve a problem but i can`t seem to be able to solve it. I have to display 12 meters inch by inch and output a blank line every 12 inches. Can someone help me with that?

Michael Mikhail

Greenhorn

Posts: 5

posted 5 years ago

1. Display 12 feet of conversions, inch by inch

As we know 1 feet = 12 inches

so 12 feet = 12/1* 12

Now my question is are you taking input from user or its hard coded.

2. Output a blank line every 12 inches

check inches every 12 and output " "

I hope this pseudo code will help otherwise where exactly you are having a problem. Is it logic or code? If its code please post code so we can direct you in right direction. Thanks

As we know 1 feet = 12 inches

so 12 feet = 12/1* 12

Now my question is are you taking input from user or its hard coded.

2. Output a blank line every 12 inches

check inches every 12 and output " "

I hope this pseudo code will help otherwise where exactly you are having a problem. Is it logic or code? If its code please post code so we can direct you in right direction. Thanks

MySQL Blog

http://mysqlearner.blogspot.com/

Michael Mikhail

Greenhorn

Posts: 5

posted 5 years ago

Ok. I got the following example

class GalToLitTable {

public static void main(String args[]) {

double gallons, liters;

int counter;

counter = 0;

for(gallons = 1; gallons <= 100; gallons++) {

liters = gallons * 3.7854; // convert to liters

System.out.println(gallons + " gallons is " +

liters + " liters.");

counter++;

// every 10th line, print a blank line

if(counter == 10) {

System.out.println();

counter = 0; // reset the line counter

}

}

}

}

and the exercise says "Adapt Project so that it prints a conversion table of inches to meters. Display 12 feet

of conversions, inch by inch. Output a blank line every 12 inches. (One meter equals

approximately 39.37 inches.)".

Think i misunderstood what it asked me to do.

class GalToLitTable {

public static void main(String args[]) {

double gallons, liters;

int counter;

counter = 0;

for(gallons = 1; gallons <= 100; gallons++) {

liters = gallons * 3.7854; // convert to liters

System.out.println(gallons + " gallons is " +

liters + " liters.");

counter++;

// every 10th line, print a blank line

if(counter == 10) {

System.out.println();

counter = 0; // reset the line counter

}

}

}

}

and the exercise says "Adapt Project so that it prints a conversion table of inches to meters. Display 12 feet

of conversions, inch by inch. Output a blank line every 12 inches. (One meter equals

approximately 39.37 inches.)".

Think i misunderstood what it asked me to do.

posted 5 years ago

Mike the logic remains the same. Everything is already given. I just converted that example for inches to meters.

1 inches = 0.0254 meters

Use above line in the loops and output

Logic: print after 12 so

Hope this helps. If you understand the mathematical logic then it should be fine.

1 inches = 0.0254 meters

Use above line in the loops and output

Logic: print after 12 so

Hope this helps. If you understand the mathematical logic then it should be fine.

MySQL Blog

http://mysqlearner.blogspot.com/

Consider Paul's rocket mass heater. |