Free AdviceGet Free Advice
Home | Get advice | Give advice | Topics | Columnists | - !START HERE! -
Make Suggestions | Sitemap

Get Advice


Search Questions

Ask A Question

Browse Advice Columnists

Search Advice Columnists

Chat Room

Give Advice

View Questions
Search Questions
Advice Topics

Login

Username:
Password:
Remember me
Register for free!
Lost Password?

Want to give Advice?

Sign Up Now
(It's FREE!)

Miscellaneous

Shirts and Stuff
Page Backgrounds
Make Suggestions
Site News
Link To Us
About Us
Terms of Service
Help/FAQ
Sitemap
Contact Us


programming


Question Posted Wednesday April 14 2010, 10:05 pm

import java.util.Scanner;
public class rectangle
{
public static void main (String[] args)
{
double int x1 = 0;
double int x2 = 0;
double int x3 = 0;
double int y1 = 0;
double int y2 = 0;
double int y3 = 0;



Scanner scan = new Scanner (System.in);

if( x1 != 0)
{
System.out.println ("enter x1: ");
x1 = scan.nextInt();
}

if(y1 != 0)
{
System.out.println ("enter y1: " );
y1 = scan.nextInt();
}

if(x2 != 0)
{
System.out.println ("enter x2: " );
x2 = scan.nextInt();
}

if(y2 != 0)
{
System.out.println ("enter y2: " );
y2 = scan.nextInt();
}

if(x3 != 0)
{
System.out.println ("enter x3: " );
x3 = scan.nextInt();
}

if(y3 != 0)
{
System.out.println ("enter y3: " );
y3 = scan.nextInt();
}

if (Distance3 > Distance 1 && Distance3 > Distance2);
{
Distance1= Math.sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));

Distance2= Math.sqrt(((x2 - x3) * (x2 - x3)) + ((y2 - y3) * (y2 - y3)));

Distance3= Math.sqrt(((x1 - x3) * (x1 - x3)) + ((y1 - y3) * (y1 - y3)));
Area = Distance1 * Distance2;


else
System.out.println ("This is anything, but a rectangle");

}
}
}


can you tell me whats wrong with this


[ Answer this question ]
Want to answer more questions in the Technology category?
Maybe give some free advice about: Internet & Web Design?


theymos answered Thursday April 15 2010, 3:13 am:
Use "double" or "int", not "double int". Since "nextInt" presumably returns an int, you should probably use that.

You shouldn't end "if" statements with semicolons. Even without the semicolon, the distanceX variables need to be defined BEFORE the "if". And the "else" is supposed to be after the "if". Probably you want something like this (starting at line 53):

Distance1=...;
Distance2=...;
Distance3=...;
Area=...;
//You wrongly used "distance 1" instead of a variable name below.
if(distance3>distance1...)
{
System.out.println("This is a rectangle.");
}
else
{
System.out.println("This is not a rectangle.");
}

[ theymos's advice column | Ask theymos A Question
]


More Questions:

<<< Previous Question: 13 year old jobs
Next Question >>> how do I make myself squrit?

Recent popular questions:
Want to give advice?

Click here to start your own advice column!

What happened here with my gamer friends?

All content on this page posted by members of advicenators.com is the responsibility those individual members. Other content © 2003-2014 advicenators.com. We do not promise accuracy, completeness, or usefulness of any advice and are not responsible for content.

Attention: NOTHING on this site may be reproduced in any fashion whatsoever without explicit consent (in writing) of the owner of said material, unless otherwise stated on the page where the content originated. Search engines are free to index and cache our content.
Users who post their account names or personal information in their questions have no expectation of privacy beyond that point for anything they disclose. Questions are otherwise considered anonymous to the general public.

[Valid RSS] eXTReMe Tracker