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 4 of 4

Thread: java program help

  1. #1
    lolalala
    Guest

    Default java program help

    i am trying to write a main method program that uses a while loop to repeatedly input four integers. the body of the while loop should break out of the loops if any of the values inputted are negative, should invoke second() to determine the 2nd highest of the 4 values read, and should print the 2nd highest value. when the loops ends, the program should print the number of sets of 4 values read, including the one that contained the negative value. i have no idea where to begin except public static int second(int a, int b, int c, int d).....please help. i just need some guidance...


  2. #2
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    495
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: java program help

    If you need guidance, post the code you have and indicate the problem (compile time error / run time error / program runs but doesn't do what you want it to / computer goes up in a puff of bright green smoke).

    If you're expecting someone here to write your code for you so you can cheat your way through whatever course you're doing, forget about it.

    db

  3. #3
    lolalala
    Guest

    Default Re: java program help

    i am not expecting for anyone to write the program for me. ill rather do it myself so that i can learn. im a beginner, so i was simply asking for some guidance. so far, this is what i have...

    import java.util.Scanner;
    public class Lab1Part3 {
    	public static int second(int a, int b, int c, int d)
     
     
    	public static void main (String[] args) {
    	System.out.printf("Input a first interger: ");
    	System.out.printf("Input a second integer: ");
     	System.out.printf("Input a third integer: ");
      	System.out.printf("Input a last integer: ");
      	Scanner getInput = new Scanner(System.in);
     
    	int i=0
    	while i<a.length {
    		if i<0
    			break
    		}
    	i++
    	}
    }


    i know its not complete, but im having trouble with the while loop....

  4. #4
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    495
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: java program help

    im having trouble with the while loop....

    Control Flow Statements (The Java™ Tutorials > Learning the Java Language > Language Basics)

    Also, recommended reading:
    How To Ask Questions The Smart Way

    db

Similar Threads

  1. Help with this java program
    By Nemphiz in forum Object Oriented Programming
    Replies: 3
    Last Post: April 13th, 2010, 04:09 AM
  2. Java LAN Chat Program
    By nevilltron in forum Java Theory & Questions
    Replies: 1
    Last Post: February 11th, 2010, 03:15 AM
  3. How do you add GUI to this java program?
    By leyla in forum AWT / Java Swing
    Replies: 1
    Last Post: October 18th, 2009, 02:32 PM
  4. Convert Java Program to Java ME code
    By rinchan11 in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: October 5th, 2009, 11:18 PM
  5. Java Program Help
    By javakid93 in forum Java Theory & Questions
    Replies: 6
    Last Post: July 27th, 2009, 12:03 PM