hi,
I got the logic ,but when I try to put it in the program I ma not getting the ouput. Can anybody please expalin me how to do it.
Logic :I have 6002 feet. how many feet in a mile? call it 4500(not sure)
6002/4500 = 1mile
6002%4500 = 1502 feet remaining
now how many feet in a yard? (1 feet = 3 yards)
1502/3 = 500 yards
1502%3 = 2 feet remainder.
so I got 1 mile, 500 yards, 2 feet out of 6002 feet
--------------------------------------------------------
public static Distances convertYards(long Yards)
// Returns yards converted into a variable of Distances.
{
Distances testyards = new Distances();
testyards.yards = (int)Yards;
testyards.miles = (int) (testyards.yards/5280);
testyards.yards = testyards.miles/3;
testyards.feet = testyards.miles/3;
return testyards;
}
public static void main(
String[] args)
{
Distances d = new Distances();
System.out.println(Distances.convertYards(6002));
}
-----------------------------------------------------------------
the output is shown as
istances@10b62c9
Please help me out.