Results 1 to 7 of 7
  1. #1
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default beginers questions

    hello everybody! i would like to say hi since i just registered here today! :) i am excited to start learning java, and hopefully it is a great gateway intro to some other languages (like C++, php, javasciprt)

    some questions here:

    1) i tried using dreamweaver for java, but when i went to the java doc, it prompted me to download the actual file... how do i view this live?

    2) i am working on a java program, where the user enters 2 values (numbers) and the program outputs the min/max number. here is what i have for max:

    Java Code:
    import java.util.Scanner;
    
    public class integers
    {
    public static void main(String[]args)
    {
    Scanner in = new Scanner(System.in);
    System.out.print("Please enter a digit: ");
    String first=in.nextLine();
    System.out.print("Please enter another digit: ");
    String second=in.nextLine();
    
    
    double largest=in.nextDouble();
    while (in.hasNextDouble())
    {
    	double input = in.nextDouble();
    	if (input>largest)
    		{
    		largest=input;
    		}
    }
    
    System.out.print("The minimum value: " + input);
    }
    }
    it seems that the program actually never ends.... :eek: i see why, because at the end, it only sets the variable input, but it does not end.

    3) I use jGRASP.. would you recommend another program? my instructor requires that we use it, but she said we can use any other ones we want... i have heard a lot about eclipse... would you recommend it for me, a beginner? and how is it different from jGRASP? Would it be more beneficial? What do you use?

    thanks!

  2. #2
    rizowski is offline Member
    Join Date
    Nov 2010
    Posts
    37
    Rep Power
    0

    Default

    Quote Originally Posted by droidus View Post
    1) i tried using dreamweaver for java, but when i went to the java doc, it prompted me to download the actual file... how do i view this live?
    Why are you using Dreamweaver for Java?

    Quote Originally Posted by droidus View Post
    2) i am working on a java program, where the user enters 2 values (numbers) and the program outputs the min/max number. here is what i have for max:
    I will try to help as much as i can, but I am nub. So if I help cool :D
    Java Code:
    import java.util.Scanner;
    
    public class integers
    {
    public static void main(String[]args)
    {
    Scanner in = new Scanner(System.in);
    System.out.print("Please enter a digit: ");
    [COLOR="SeaGreen"]//why are you using String for doubles below? 
    // You are storing the input into a string and assign that into first. if you want to use the number 
    //they enter I believe you need it to be a int, double, long, short.[/COLOR]
    String first=in.nextLine();
    
    System.out.print("Please enter another digit: ");
    [COLOR="SeaGreen"]//why are you using String for doubles below?[/COLOR]
    String second=in.nextLine();
    
    
    double largest=in.nextDouble();
    while (in.hasNextDouble())
    {
    	double input = in.nextDouble();
    	if (input>largest)
    		{
    		largest=input;
    		}
    }
    
    System.out.print("The minimum value: " + input);
    }
    }


    Quote Originally Posted by droidus View Post
    3) I use jGRASP.. would you recommend another program? my instructor requires that we use it, but she said we can use any other ones we want... i have heard a lot about eclipse... would you recommend it for me, a beginner? and how is it different from jGRASP? Would it be more beneficial? What do you use?

    thanks!
    I personally use Eclipse because it gives you really good information on problems, You can also use the debug and step right through each step your program goes through. Makes infinite loops very easy to find if your program holds up. Eclipse also has auto complete, but being a beginner sometimes that is not always a good thing because you want to know what your writing.

  3. #3
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default

    1) there is an option to create a java file in dw. just wondering.

    2) instead of
    Java Code:
    String first=in.nextLine();
    would i want "Double first=..."?

  4. #4
    NxTD is offline Member
    Join Date
    Feb 2011
    Posts
    1
    Rep Power
    0

    Post Possible solution

    You were trying to create strings in which to hold the numbers but when working with numbers you should either use int or double for your variable
    Also instead of using while, I found it much easier to accomplish the goal by using a simple if else statement

    Java Code:
    import java.util.Scanner;
    
    public class integers
    {
    public static void main(String[]args)
    {
    Scanner in = new Scanner(System.in);
    System.out.print("Please enter a digit: ");
    Double first=in.nextDouble();
    System.out.print("Please enter another digit: ");
    Double second=in.nextDouble();
    
    if(first>second){
    	System.out.println("The max number is "+first);
    	System.out.println("Teh min number is "+second);
    }
    else if (second>first)
    {	System.out.println("The max number is "+second);
    System.out.println("The min number is "+first);
    	}
    
    }
    }
    Hope that helps

  5. #5
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Yeah, don't use dreamweaver. I suggest Netbeans or Eclipse. Netbeans is my personal favorite Welcome to NetBeans

  6. #6
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default

    works like a dime; kudos, NxTD! :)

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

    Default

    Ahh good!

    Another n00b spoonfed the answer and saved from learning to do their own homework.

Similar Threads

  1. questions
    By amaliutz in forum New To Java
    Replies: 13
    Last Post: 02-02-2011, 06:13 PM
  2. a good site for java beginers
    By gcdas04 in forum Reviews / Advertising
    Replies: 1
    Last Post: 01-12-2009, 09:20 AM
  3. questions for 1yr exp
    By rahaman.athiq in forum Java Servlet
    Replies: 2
    Last Post: 11-26-2008, 01:13 AM
  4. I have Questions -_-
    By ChazZeromus in forum New To Java
    Replies: 5
    Last Post: 09-13-2008, 08:08 PM
  5. New java site for beginers
    By windyawarnapura in forum Java Software
    Replies: 1
    Last Post: 03-14-2008, 06:02 PM

Posting Permissions

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