Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 20 of 20

Thread: Need help!!!!!

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need help!!!!!

    // This program prints the numbers that a user enters through another number entered by user along
    // with these values multiplied by 2 and by 3.
    // Input:  two integer not necessary in order
    // Output: Prints the smaller entered number through the larger along with their values multiplied by 2 and by 3. 
    <
    import javax.swing
     
    public class FinalExamFall2012
    {
    	public static void main(String args[])
    	{
    		String head1 = "Number: ";
    		String head2 = "Multiplied by 2: ";
    		String head3 = "Multiplied by 3:  ";				
    		int numberCounter = 0; 	
    		int doubled;		// Stores the number multiplied by 2.
    		int tripled; 	        // Stores the number multiplied by 3.
    		string SmallerNumString;
    		String LargerNumString;
    		double SmallerNum;
    		double LargerNum;
    		int Number;
    		final int NUM_LOOPS = 2; 
                    //decalr variables to accept input
                    //convert input into integers
                    //int SmallerNum, LargerNum;
                    //assign the small number entered to SmallerNum using if condition
     
    		if (numberCounter > LargerNum)
    		{
      		SmallerNum = LargerNum;
    		}
     
      		LargerNum = numberCounter;
    		{
     
    		else 
    		(numberCounter > SmallerNum)
    		{
     
      		SmallerNum = numberCounter;
     
    		}
     
                    //assign larger num to appropriate variable
    		Number = JOptionPane.showInputDialog("Enter Number: ");
     
    		SmallerNum = Double.parseDouble(SmallerNumString);
    		LargerNum = Double.parseDouble(largeerNumString);
     
    		System.out.println(SmallerNum + "  through ” + LargerNum + “  multiplied by 10 and by 100" + "\n");
     
    		numberCounter = SmallerNum; 
    		// use a do while loop
    		do
    		{
    		doubled = numberCounter * 2;
    		tripled = numberCounter * 3;
    			 // Multiply by 2.
    			 // Multiply by 3.
    			System.out.println(head1 + numberCounter);
    			System.out.println(head2 + doubled);
    			System.out.println(head3 + tripled);
    			numberCounter++;
    			System.out.print("\n");
    		} 
     
    		while(numberCounter  <= NUM_LOOPS );
     
    		//cosntruct while loop condition
                    // End of do while loop.
    		// This is the work done in the endOfJob() method
                    System.exit(0);
    	} // End of main() method.
     
    } 
    // End class.
    >

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,214
    Thanks
    52
    Thanked 2,294 Times in 2,265 Posts

    Default Re: Need help!!!!!

    Do you have a question you meant to ask?

    Please edit your post and wrap your code with code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help!!!!!

    Yes I want to know how I can make it run?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,214
    Thanks
    52
    Thanked 2,294 Times in 2,265 Posts

    Default Re: Need help!!!!!

    To run a java program, first compile it with the javac command, then execute it with the java command.
    See an example in the tutorial: "Hello World!" for Microsoft Windows (The Java™ Tutorials > Getting Started > The "Hello World!" Application)
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help!!!!!

    It is not compiling. I have errors, I do not know what I did wrong

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,214
    Thanks
    52
    Thanked 2,294 Times in 2,265 Posts

    Default Re: Need help!!!!!

    I have errors
    Copy the full text of the error messages and paste it here.

    Please edit your post and wrap your code with code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help!!!!!

    ok

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,214
    Thanks
    52
    Thanked 2,294 Times in 2,265 Posts

    Default Re: Need help!!!!!

    Where are the error messages?
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help!!!!!

    on the else and it is not compelling
    the program is suppose to Prints the smaller entered number through the larger along with their values multiplied by 2 and by 3.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,214
    Thanks
    52
    Thanked 2,294 Times in 2,265 Posts

    Default Re: Need help!!!!!

    Copy the full text of the error messages and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help!!!!!

    can't copy the error, but here it is
    'else' without if

    else
    ^

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,214
    Thanks
    52
    Thanked 2,294 Times in 2,265 Posts

    Default Re: Need help!!!!!

    Check that the {}s are properly paired. The statement should look somthing like this:
      if(some condition) {
        //  do some stuff here
      } else {
       // do something else here
      }
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help!!!!!

    error message of:
    illegal start of type
    }else{
    ^

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,214
    Thanks
    52
    Thanked 2,294 Times in 2,265 Posts

    Default Re: Need help!!!!!

    Check that the {}s are properly paired.

    I can't tell why the compiler gives that error without seeing a lot of the code that comes before the statement with the error.
    If you don't understand my answer, don't ignore it, ask a question.

  15. #15
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help!!!!!

    yes

  16. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,214
    Thanks
    52
    Thanked 2,294 Times in 2,265 Posts

    Default Re: Need help!!!!!

    Yes ???
    If you don't understand my answer, don't ignore it, ask a question.

  17. #17
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help!!!!!

    I placed them exactly the way you placed it. it gave me the same error message

  18. #18
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,214
    Thanks
    52
    Thanked 2,294 Times in 2,265 Posts

    Default Re: Need help!!!!!

    I can't see what you did if you don't post the code that shows the problem.
    If you don't understand my answer, don't ignore it, ask a question.

  19. #19
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help!!!!!

    <// This program prints the numbers that a user enters through another number entered by user along
    // with these values multiplied by 2 and by 3.
    // Input:  two integer not necessary in order
    // Output: Prints the smaller entered number through the larger along with their values multiplied by 2 and by 3. 
     
    //import javax.swing
     
    public class FinalExamFall2012
    {
    	public static void main(String args[])
    	{
    		String head1 = "Number: ";
    		String head2 = "Multiplied by 2: ";
    		String head3 = "Multiplied by 3:  ";				
    		int numberCounter = 0; 	
    		int doubled;		// Stores the number multiplied by 2.
    		int tripled; 	        // Stores the number multiplied by 3.
    		string SmallerNumString;
    		String LargerNumString;
    		double SmallerNum;
    		double LargerNum;
    		int Number;
    		final int NUM_LOOPS = 2; 
                    //decalr variables to accept input
                    //convert input into integers
                    //int SmallerNum, LargerNum;
                    //assign the small number entered to SmallerNum using if condition
     
    		if (numberCounter > LargerNum)
    		{
      		SmallerNum = LargerNum;
    		}
     
      		LargerNum = numberCounter;
     
     
    		  } else {
    		(numberCounter > SmallerNum)
    		{
     
      		SmallerNum = numberCounter;
     
    		}
     
                    //assign larger num to appropriate variable
    		Number = JOptionPane.showInputDialog("Enter Number: ");
     
    		SmallerNum = Double.parseDouble(SmallerNumString);
    		LargerNum = Double.parseDouble(LargerNumString);
     
    		System.out.println(SmallerNum + "  through ” + LargerNum + “  multiplied by 10 and by 100" + "\n");
     
    		numberCounter = SmallerNum; 
    		// use a do while loop
    		do
    		{
    		doubled = numberCounter * 2;
    		tripled = numberCounter * 3;
    			 // Multiply by 2.
    			 // Multiply by 3.
    			System.out.println(head1 + numberCounter);
    			System.out.println(head2 + doubled);
    			System.out.println(head3 + tripled);
    			numberCounter++;
    			System.out.print("\n");
    		} 
     
    		while(numberCounter  <= NUM_LOOPS );
     
    		//cosntruct while loop condition
                    // End of do while loop.
    		// This is the work done in the endOfJob() method
                    System.exit(0);
    	} 
    		// End of main() method.
     
    } 
    		// End class.>

  20. #20
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,214
    Thanks
    52
    Thanked 2,294 Times in 2,265 Posts

    Default Re: Need help!!!!!

    Check that the {}s are correctly paired.
    If you don't understand my answer, don't ignore it, ask a question.

Tags for this Thread