Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Project Freezing(My project freezes whenever i use a decimal number(using a DOUBLE) but works fine with whole numbers. Feel free to try the code out using the zip file or copying and pasting the code)
Project Freezing [message #1773629] Sun, 01 October 2017 20:13 Go to next message
Ethan Flower is currently offline Ethan FlowerFriend
Messages: 1
Registered: October 2017
Junior Member
My project freezes whenever i use a decimal number(using a DOUBLE) but works fine with whole numbers. Feel free to try the code out using the zip file or copying and pasting the code below. If you can fix this, just send me the edited code back my way. this is just a personal little project of mine


import java.util.Scanner;

/**
*
*/

/**
* @author Ethan Flower
*
*/
public class EuclidsAlgorithm {
public static void main(String[] args) {
Scanner scan = new Scanner (System.in);
System.out.println("Type in the unit you are using(all lowercase, ex. m for metres):");
String mUnit = scan.nextLine();
System.out.println("Type in the rectangle length:");
double L = scan.nextDouble();
System.out.println("Type in the rectangle width:");
double W = scan.nextDouble();
if (L<W) {System.out.println("...so width is greater than length now?..");}
//double holder;
//holder = L;
while(L != W) {
if (L > W) {
L -= W;
} else if (L < W) {
W -= L;
}
//if ((L/10 < holder) && mUnit == "cm") {mUnit = "mm";}
//else if ((L/100 < holder) && mUnit == "m") {mUnit = "cm";}
//else if ((L/1000 < holder) && mUnit == "km") {mUnit = "m";}
}

if (L == W) {
System.out.println("The largest sqare can be "+ L + mUnit +" and "+ W + mUnit +".");
}

}
}
Re: Project Freezing [message #1773630 is a reply to message #1773629] Sun, 01 October 2017 22:15 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

This is a forum dedicated to Eclipse and projects developed at eclipse.org, not for general programming questions. Followup generally also belongs in the forum itself. You might try Stack Overflow instead, but this looks a lot like a homework problem, so they're going to want a clearer explanation of exactly when it freezes and what you've already tried to solve this problem yourself.

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Unable to start Eclipse Rdz Environment
Next Topic:Copying projects?
Goto Forum:
  


Current Time: Fri Apr 26 05:19:21 GMT 2024

Powered by FUDForum. Page generated in 0.07666 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top