Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 30-10-2009
Member
 
Join Date: Oct 2009
Posts: 1
question Java anyone?

Hello everyone my name is David. I'm new to the arena and I hope to further my knowledge and can help others as others will help me. To start off I need some quick java help please! I have a project due today by noon and well I'm a bit lost...My message appears but then my program will not compile? I need my message to show up and then be able to input my values and finish the program. Any help please? I can already input the values without my message being in there but I need that. Thanks David.
Here is the code:

import java.util.Scanner;

public class TrianglesProject2
{
public static void main(String [] args){
System.out.println("Welcome to David's Triangle Solving Program! Please Enter Side 1, Side 2, and Side 3 Now. Also make sure they equal 180 Degrees!");
}

{
Scanner input = new Scanner(System.in);
int ang_1 = input.nextInt();
int ang_2 = input.nextInt();
int ang_3 = input.nextInt();
int total = ang_1+ang_2+ang_3;

if(total!=180)
{
System.out.println("Please re-enter angles so that they equal 180!");
}

else if(ang_1==90||ang_2==90||ang_3==90)
{
System.out.println("Right Triangle");
}

else if((ang_1==ang_2&&ang_1!=ang_3)||(ang_1==ang_3&&an g_1!=ang_2)||(ang_2==ang_3&&ang_2!=ang_1))
{
System.out.println("Isosceles Triangle");
}

else if(ang_1==ang_2&&ang_2==ang_3)
{
System.out.println("Equilateral Triangle");
}
}
}// end class
Reply With Quote
  #2  
Old 30-10-2009
Member
 
Join Date: Dec 2008
Posts: 3
Re: Java anyone?



You had extra brackets and extra space

have corrected the source,

import java.util.Scanner;

public class TrianglesProject2{
public static void main(String [] args){
System.out.println("Welcome to David's Triangle Solving Program! Please Enter Side 1, Side 2, and Side 3 Now. Also make sure they equal 180 Degrees!");
Scanner input = new Scanner(System.in);
int ang_1 = input.nextInt();
int ang_2 = input.nextInt();
int ang_3 = input.nextInt();
int total = ang_1+ang_2+ang_3;

if(total!=180)
System.out.println("Please re-enter angles so that they equal 180!");

else if(ang_1==90||ang_2==90||ang_3==90)
System.out.println("Right Triangle");

else if((ang_1==ang_2&&ang_1!=ang_3)||(ang_1==ang_3&&ang_1!=ang_2)||(ang_2==ang_3&&ang_2!=ang_1))
System.out.println("Isosceles Triangle");

else if(ang_1==ang_2&&ang_2==ang_3)
System.out.println("Equilateral Triangle");
}
}



Reply With Quote
  #3  
Old 31-10-2009
Member
 
Join Date: Feb 2009
Posts: 96
Re: Java anyone?

use this one it's mistake free

Code:
import java.util.Scanner;

public class TrianglesProject2{
public static void main(String [] args){
System.out.println("Welcome to David's Triangle Solving Program!\n" );
System.out.println("Please Enter Side 1, Side 2, and Side 3 Now.\n" );
System.out.println(" Also make sure they equal 180 Degrees!\n");

Scanner input = new Scanner(System.in);
int ang_1 = input.nextInt();
int ang_2 = input.nextInt();
int ang_3 = input.nextInt();
int total = ang_1+ang_2+ang_3;

if(total!=180){
System.out.println("Please re-enter angles so that they equal 180!");
}
else if(ang_1==90|ang_2==90|ang_3==90){
System.out.println("Right Triangle");
}
else if((ang_1== ang_2&&ang_1!= ang_3)|(ang_1==ang_3&&ang_1!=ang_2)|(ang_2==ang_3&&ang_2!=ang_1)){
System.out.println("Isosceles Triangle");
}
else if(ang_1==ang_2&&ang_2==ang_3)

System.out.println("Equilateral Triangle");

}
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags:



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Java anyone?"
Thread Thread Starter Forum Replies Last Post
Java Auto Updater wants me to update java everyday in Windows 7 minajoh Windows Software 4 04-09-2013 11:04 PM
Setting Of Java to The Point At Manual Java winni Software Development 4 10-01-2011 10:05 PM
Java Programming using Adventnet SNMP Java API ROCKING_Suhas Software Development 5 17-07-2010 06:52 AM
Link List Example in Java Sample program in Java trickson Software Development 2 04-08-2009 08:23 PM


All times are GMT +5.5. The time now is 09:09 AM.