Results 1 to 3 of 3

Thread: Java anyone?

  1. #1
    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

  2. #2
    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");
    }
    }




  3. #3
    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");
    
    }
    }

Similar Threads

  1. Replies: 4
    Last Post: 04-09-2013, 11:04 PM
  2. Setting Of Java to The Point At Manual Java
    By winni in forum Software Development
    Replies: 4
    Last Post: 10-01-2011, 10:05 PM
  3. Java Programming using Adventnet SNMP Java API
    By ROCKING_Suhas in forum Software Development
    Replies: 5
    Last Post: 17-07-2010, 06:52 AM
  4. Link List Example in Java Sample program in Java
    By trickson in forum Software Development
    Replies: 2
    Last Post: 04-08-2009, 08:23 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,824,002.47771 seconds with 16 queries