Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do I get the $ sign before the loan amount in the output.. Kind of confused

ID: 3888296 • Letter: H

Question

How do I get the $ sign before the loan amount in the output.. Kind of confused tried a lot but failed. Please help.. public static void main(String[1 args) t 121 13 14 15 16 Scanner input new Scanner(System.in); System.out.println("What is the loan amount? ") int loanamount = input . nextInt(); 18 19 20 21 System.out.println("What is the down payment? "): int downpayment = input . next!nt(); out.print("Have you held your current job for at least a year? "); current job String input . next(); 23 24 25 26 27 28 System.out.println("what is your annual salary? "); int annualsalary = input.next Int(); if(downpayment >= (.2 * Ioanamount)) { System.out.println("You are eligilble for this loan ofoanamount): System.out.printf("You are eliglible for this loan of "loanamount); System.out.printf("You are not eligible for this loan of $" loanamount): else if ((currentjob-= "yes") 66 (annualsalary >_ (loanamount * .5))) { 31 32 elset 34 35 main> if (downpayment >= (0.2. Ioanamount) else if ((current ob== yes")&& annua sala y> loa anc , week4labtue.Week4LabTue> Output-week4 LabTue(run) run: What is the loan amount? 50000 What is the down payment? 10000 Have you held your current job for at least a year? yes What is your annual salary? 20000 You are eligilble for this loan of 50080 BUILD SUCCESSFUL (total time: 12 seconds)

Explanation / Answer

Hi, for the data you have entered, the if statement (line 28) was executing, not the else statement. And in 'if' statement you have not mentioned the dollar sign in the print statement. That's why you are not able to get the dollar sign.

In print statement the dollar sign will work perfectly. You just need to add the dollar sign in line number 28 like you did in line number 31.

the condition was downpayment >= .2* loanamount i.e. 10000 >=0.2*50000 i.e. 10000>=10000 which is true..

Please give the thumbs up, if it is helpful for you!!. Let me know if you have any doubts.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote