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

Thread: newbie needs help with for loop

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy newbie needs help with for loop

    Hi there,
    Not sure where to start with this can anybody help?

    Write Java program that determines if someone can get a mortgage. The rules are that one can only get mortgage approval if they have a salary over €40,000 or they have both savings over €85,000 and are over 25.

    Add a loop to continually process people until someone enters a salary of zero


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: newbie needs help with for loop

    What have you done so far, or need help with? We won't do if for you.

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Re: newbie needs help with for loop

    class samplepaperq3c{

    public static void main(String[]args){


    double salary = 0;
    double savings = 0;
    int age = 0;

    do
    {

    do
    {

    System.out.println("Please enter your current age");
    age=Keyboard.readInt();
    System.out.println(""); //keeps the console screen clear

    System.out.println("Please enter your current Salary");
    salary=Keyboard.readDouble();
    System.out.println(""); //keeps the console screen clear

    System.out.println("Please enter your current savings approximately");
    savings=Keyboard.readDouble();
    System.out.println(""); //keeps the console screen clear

    if(age >= 25 && salary >= 40000 && savings >=85000)
    {
    System.out.println("you are eligible for a morgage");
    }

    else
    {
    System.out.println("You are not eligible for a morgage");
    }




    }while (age > 25 && salary > 40000 && savings >=85000); //end of do while loop


    System.out.println("thank you for using this program");
    System.out.println(""); //keeps the console screen clear

    }while(salary!= 0); //end of do while loop

    }//end of main method

    }//end of class

    Thanks for your reply. I just did this up. It seems to do the job that they are asking. how would you approach this or do you think this is ok

Similar Threads

  1. Newbie needs help in simple servlet program
    By visitor1078 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 19th, 2009, 01:46 PM
  2. Replies: 6
    Last Post: October 20th, 2009, 06:33 AM
  3. Newbie...
    By jchan in forum Member Introductions
    Replies: 2
    Last Post: September 28th, 2009, 02:39 AM
  4. Replies: 8
    Last Post: August 6th, 2009, 01:35 PM
  5. I'm a newbie
    By r12ki in forum Member Introductions
    Replies: 2
    Last Post: June 1st, 2009, 06:38 AM