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: Re: Beginner programmer here

  1. #1
    Junior Member
    Join Date
    Mar 2019
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Beginner programmer here

    import java.util.Scanner;
    public class LoanProgram2{
    public static void main (String [] args){
    Scanner input= new Scanner(System.in);

    System.out.println("Enter the loan amount: ");
    double InitialAmountLoan = input.nextDouble();

    System.out.println("Enter interest rate: ");
    double AnnualInterestRate = input.nextDouble();

    System.out.println("Please enter the monthly repayment amount> ");
    double MonthlyRepayment = input.nextDouble();

    double InitialBalance = +InitialAmountLoan;
    System.out.println("Original loan Amount = " +InitialBalance );
    System.out.println();

    double InitialInterestRate = +AnnualInterestRate;
    System.out.println("Interest rate is = " +InitialInterestRate );
    System.out.println();

    double InitialMonthlyPayment = +MonthlyRepayment;
    System.out.println("Monthly Payment is = " +InitialMonthlyPayment);
    System.out.println();

    double AmountOfInterest =0;

    double MonthlyRate = (+AnnualInterestRate/100) /12;
    double Balance =InitialAmountLoan + (+InitialAmountLoan * +MonthlyRate) - +MonthlyRepayment;

    int count = 1;

    System.out.println("Balance at Month " +count+ " is " +Balance+ " after making a payment of " +MonthlyRepayment );
    System.out.println();

    while (Balance > 0){
    if (Balance > 100)
    Balance = Balance + (+Balance * +MonthlyRate) - +MonthlyRepayment;

    else if (Balance <9)
    break;

    count = count +1;

    System.out.println("Balance at Month " +count+ " is " +Balance+ " after making a payment of " +MonthlyRepayment );
    System.out.println();
    }


    System.out.println("Loan will take " +count+ " months to pay off a lone of " +InitialAmountLoan);

    }
    }

    THIS ARE THE VALUES I USED TO TEST THE PROGRAM

    100000, 6.5 AND 1500 FOR THIS RUN FINE
    BUT FOR THIS "100000, 6.5 AND 200"I WANT IT TO STOP AND PRINT "IT IS TO LOW"
    PLEASE, HELP ME FIND SOLUTION TO THIS. THANKS

  2. #2
    Junior Member
    Join Date
    Mar 2019
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please help me to check what to do to stop the loop after putting the second value

    import java.util.Scanner;
    public class LoanProgram2{
    public static void main (String [] args){
    Scanner input= new Scanner(System.in);

    System.out.println("Enter the loan amount: ");
    double InitialAmountLoan = input.nextDouble();

    System.out.println("Enter interest rate: ");
    double AnnualInterestRate = input.nextDouble();

    System.out.println("Please enter the monthly repayment amount> ");
    double MonthlyRepayment = input.nextDouble();

    double InitialBalance = +InitialAmountLoan;
    System.out.println("Original loan Amount = " +InitialBalance );
    System.out.println();

    double InitialInterestRate = +AnnualInterestRate;
    System.out.println("Interest rate is = " +InitialInterestRate );
    System.out.println();

    double InitialMonthlyPayment = +MonthlyRepayment;
    System.out.println("Monthly Payment is = " +InitialMonthlyPayment);
    System.out.println();

    double AmountOfInterest =0;

    double MonthlyRate = (+AnnualInterestRate/100) /12;
    double Balance =InitialAmountLoan + (+InitialAmountLoan * +MonthlyRate) - +MonthlyRepayment;

    int count = 1;

    System.out.println("Balance at Month " +count+ " is " +Balance+ " after making a payment of " +MonthlyRepayment );
    System.out.println();

    while (Balance > 0){
    if (Balance > 100)
    Balance = Balance + (+Balance * +MonthlyRate) - +MonthlyRepayment;

    else if (Balance <9)
    break;

    count = count +1;

    System.out.println("Balance at Month " +count+ " is " +Balance+ " after making a payment of " +MonthlyRepayment );
    System.out.println();
    }


    System.out.println("Loan will take " +count+ " months to pay off a lone of " +InitialAmountLoan);

    }
    }

    THIS ARE THE VALUES I USED TO TEST THE PROGRAM

    100000, 6.5 AND 1500 FOR THIS RUN FINE
    BUT FOR THIS "100000, 6.5 AND 200"I WANT IT TO STOP AND PRINT "IT IS TO LOW"
    PLEASE, HELP ME FIND SOLUTION TO THIS. THANKS

  3. #3
    Junior Member
    Join Date
    Mar 2019
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please help me to check what to do to stop the loop after putting the second value

     import java.util.Scanner;
    public class LoanProgram2{
    	public static void main (String [] args){
    		Scanner input= new Scanner(System.in);
     
    		System.out.println("Enter the loan amount: ");
    		double InitialAmountLoan = input.nextDouble();
     
    		System.out.println("Enter interest rate: ");
    		double AnnualInterestRate = input.nextDouble();
     
    		System.out.println("Please enter the monthly repayment amount> ");
    		double MonthlyRepayment = input.nextDouble();	
     
    		double InitialBalance = +InitialAmountLoan;
    		System.out.println("Original loan Amount = " +InitialBalance );
    		System.out.println();
     
          double InitialInterestRate = +AnnualInterestRate;
    		System.out.println("Interest rate is = " +InitialInterestRate );
    		System.out.println();
     
         double InitialMonthlyPayment = +MonthlyRepayment;
    		System.out.println("Monthly Payment is = " +InitialMonthlyPayment);
    		System.out.println();
     
    		double AmountOfInterest =0;
     
    		double MonthlyRate = (+AnnualInterestRate/100) /12;
    		double Balance =InitialAmountLoan + (+InitialAmountLoan * +MonthlyRate) - +MonthlyRepayment;
     
    		int count = 1;
     
    		System.out.println("Balance at Month " +count+ " is " +Balance+ " after making a payment of " +MonthlyRepayment );
            System.out.println();
     
    		while (Balance > 0){
    	    if (Balance > 100)
    	       Balance = Balance + (+Balance * +MonthlyRate) - +MonthlyRepayment;
     
    	    else if (Balance <9)
    	           	break;
     
    			count = count +1;	 
     
    			System.out.println("Balance at Month " +count+ " is " +Balance+ " after making a payment of " +MonthlyRepayment );
    		    System.out.println();
        }
     
     
    		    System.out.println("Loan will take " +count+ " months to pay off a lone of " +InitialAmountLoan);
     
    }
    }

    THIS ARE THE VALUES I USED TO TEST THE PROGRAM

    100000, 6.5 AND 1500 FOR THIS RUN FINE
    BUT FOR THIS "100000, 6.5 AND 200"I WANT IT TO STOP AND PRINT "IT IS TO LOW"
    PLEASE, HELP ME FIND SOLUTION TO THIS. THANKS

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Please help me to check what to do to stop the loop after putting the second value

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.

    STOP AND PRINT "IT IS TO LOW"
    Can you use an if statement to detect if the value is too low and then print out a message?

    What should the program do after printing out the message? Should it try to get a better value or should it end execution?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Beginner programmer here
    By Erina in forum Member Introductions
    Replies: 1
    Last Post: March 15th, 2019, 01:50 PM
  2. Projects For A Beginner Programmer
    By tazeunite00 in forum Java Theory & Questions
    Replies: 5
    Last Post: September 5th, 2014, 10:57 AM
  3. JAVA Programmer Beginner
    By tigger7391 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 17th, 2014, 02:48 AM
  4. Would appreciate help (Beginner programmer)
    By TSSF44 in forum Java Theory & Questions
    Replies: 5
    Last Post: October 18th, 2013, 04:39 AM
  5. Beginner java programmer!
    By chrisivey1980 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: April 23rd, 2011, 03:06 AM