March 19th, 2013, 10:44 PM

Division problem please help
Hey guys im stuck I need to use a do while loop to count the time s it takes for 1 / 2 to equal .0001.
this is what I have so far:
public class Divide {
public static void main(String[] args) {
double count = 1;
double x=1f;
double y=2f;
double z;
do {
z= x/y;
System.out.println("Count is: " + count);
count++;
} while (z <=.0001);
}
}
not sure how to return the value to keep doing the division.
March 19th, 2013, 11:16 PM

stuck
been playin around with this but cant get it to work properly heres my new code:
public class Divide {
public static void main(String[] args) {
double n=1;
double Total = returnVal(n);
System.out.println();
}
public static double returnVal(double x){
double value = 1;
double i = x;
while(value <=.0001);
value = value/2;
i++;
return value;
}
}
March 19th, 2013, 11:28 PM

initial problem
this is the initial problem if that helps:
If you divide 1 by 2, you get 0.5. If you divide it again by 2, you get 0.25. Write a
program using “do…while” loop to calculate and output the number of times you have to
divide 1 by 2 to get a value less than one tenthousands (0.0001).
March 20th, 2013, 12:46 AM

ahhh
alright pretty sure im wasting my time since no one will help me but now im 5 hours in on this problem and this is what i have. it doesnt work but i dont know what else to do
public class Divide {
public static void main(String[] args) {
double n =1;
double Final=NumR(n);
System.out.println(Final);
}
public static double NumR(double z){
double x=2;
double i =z;
double total;
do{
total =i/x;
i++;
}
while(i >=.0001);
return i;
}}
March 20th, 2013, 01:34 AM

I really need some help here Anyone!?!?!?!?!?!?!?
March 20th, 2013, 03:39 AM

possible solution please check!!!
this is what I have now I believe it works please check
public class Divide {
public static void main(String[] args) {
double x = 1;
double count = 0;
double tempNum = x / 2;
while (tempNum > .0001){
tempNum = tempNum / 2;
count++;
System.out.println("The number " + x + " is divisible by two " + count + " times");
}
}
}