How do i ??
Results 1 to 4 of 4

Thread: How do i ??

  1. #1
    Member
    Join Date
    Oct 2001
    Posts
    59

    How do i ??

    How do i create a program in java that lets the user enter three numbers and outputs the largest of the three numbers entered ?

  2. #2
    AO übergeek phishphreek's Avatar
    Join Date
    Jan 2002
    Posts
    4,325
    Maybe take a look at some of these books.

    http://av.stanford.edu/books/thinking/

    You may want to read some java tutorials too...

    http://java.sun.com/docs/books/tutorial/
    http://www.google.com/search?hl=en&i...orials&spell=1

    BTW: You posted in the wrong forum. This is for original tutorials only...
    Quitmzilla is a firefox extension that gives you stats on how long you have quit smoking, how much money you\'ve saved, how much you haven\'t smoked and recent milestones. Very helpful for people who quit smoking and used to smoke at their computers... Helps out with the urges.

  3. #3
    Elite Hacker
    Join Date
    Mar 2003
    Posts
    1,407
    Code:
    import java.io.*;
    
    public class WordTest 
    {
    	public static void main(String args[]) throws IOException
    	{
    		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    		System.out.print("Enter first number: ");
    		int one = Integer.parseInt(input.readLine());
                    System.out.print("Enter second number: ");
    		int two = Integer.parseInt(input.readLine());
                    System.out.print("Enter third number: ");
    		int three = Integer.parseInt(input.readLine());
                    if(one>two && one>three){
                       System.out.println(one + " is the largest number you input");	
                    }
                    else if(two>one && two>three){
                       System.out.println(two + " is the largest number you input");	
                     }
                    else{
                       System.out.println(three + " is the largest number you input");	
                     }
    	}
    }
    I haven't tested this but it should be what you want.


    edit
    You are right phishphreek80, but I can't resist. It can really help some people to actually see the code of a program though. Plus I think there is a little flaw in my program. Maybe I won't fix it, but I will say what it is. There could be a problem if two of the numbers are the same.

  4. #4
    AO übergeek phishphreek's Avatar
    Join Date
    Jan 2002
    Posts
    4,325
    h3r3tic: Its nice that you help him out with this, but they aren't going to learn anything if you do their homework for them...

    EDIT:

    You're right too, it helps to see the code and examples. Thats why I only posted links to references.

    More of a point in the right direction.
    Quitmzilla is a firefox extension that gives you stats on how long you have quit smoking, how much money you\'ve saved, how much you haven\'t smoked and recent milestones. Very helpful for people who quit smoking and used to smoke at their computers... Helps out with the urges.

Posting Permissions

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