Results 1 to 4 of 4

Thread: Java Question.

  1. #1
    Taszk is offline Member
    Join Date
    May 2011
    Posts
    29
    Rep Power
    0

    Default Java Question.

    Is it possible to have a java program open a picture on the web? If so does it require a lot of coding? This is my program and i would like to have whatever Triangle that is identified show a picture of the Triangle from the web. It isn't necessary but if it doesn't require to much coding I'm for it.
    Java Code:
    import java.util.*;
    public class FinalProjectBeta{
    	public static void main(String[] args)
    		{int a=1, b, c, p;
    			Scanner in=new Scanner(System.in);			
    			
    	while(a!=0)
    		{System.out.println("Enter the length of side \"a\" of the triangle to begin:");
    		 a=in.nextInt();
    	if(a==0)
    		System.exit(0);
    		 System.out.println("Enter the length of side \"b\" of the triangle:");
    		 b=in.nextInt();
    		 System.out.println("Enter the length of side \"c\" of the triangle:");
    		 c=in.nextInt();
    			
    	getTriType(a,b,c);
    	getAreaPerimeter(a,b,c);
    		}
    	}
    public static void getTriType(int a, int b, int c)
    	{if(a==0||b==0||c==0||a<0||b<0||c<0)
    		{System.out.println("According to the given sides there was one or more invalid sides of a Triangle.");
    		System.exit(0);
    		}
    	else if(a==b&&a==c&&b==c)
    		{System.out.print("According to the given sides, since a,b and c are equal ");
    		 System.out.println("the triangle is an Equilateral Triangle.");
    		}
    	else if(a==b||a==c||b==a||b==c||c==a||c==b)
    		{System.out.print("According to the given sides, since two sides are equal ");
    		 System.out.println("the triangle is an Isosceles Triangle.");
    		}
    	else
    		{System.out.print("According to the given sides, since a,b and c are not equal ");
    		 System.out.println("the triangle is a Scalene Triangle.");
    		}
    	}
    	
    public static double getAreaPerimeter(int a, int b, int c)
    	{double s = 0.5 * (a + b + c);
    	 double area = Math.sqrt(s*(s-a)*(s-b)*(s-c));
    	 double p = a+b+c;
    	 
    	 System.out.println("The Area is "+area+" and the Perimeter is "+p+".");
    	 System.out.println();
    	 return area;
    	}
    }
    If possible can someone put me on the right track it'll be something completely new to me.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    What I would do is download the images (providing it is not illegal) and package them up with your code in a jar file.

  3. #3
    Taszk is offline Member
    Join Date
    May 2011
    Posts
    29
    Rep Power
    0

    Default

    Quote Originally Posted by Junky View Post
    What I would do is download the images (providing it is not illegal) and package them up with your code in a jar file.
    I see. What happens if I send the program over to someone so that they could view it? Wouldn't the pictures downloaded only be able to open up on my end?

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    If everything is packed up in a jar file (code and images), you send them the jar. Provided you have created the jar file correctly (find a tutorial) all the user has to do is double click it to run.

Similar Threads

  1. Help with Java Question
    By joe98 in forum New To Java
    Replies: 3
    Last Post: 03-29-2011, 10:09 AM
  2. Replies: 33
    Last Post: 01-21-2011, 03:07 PM
  3. Need help with java question
    By ccie007 in forum New To Java
    Replies: 23
    Last Post: 05-18-2010, 06:32 PM
  4. Java question
    By TGH in forum New To Java
    Replies: 12
    Last Post: 11-27-2009, 02:05 PM
  5. question about java rmi
    By hakimade in forum Advanced Java
    Replies: 1
    Last Post: 07-01-2009, 07:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •