solved.
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.
solved.
Last edited by ryuumaru; June 28th, 2014 at 01:48 PM. Reason: solved.
Welcome to the forum! Thanks for taking the time to learn how to post code correctly. If you haven't already, please read this topic to learn other useful info for new members.
Where in the code are you trying to do this part?I cannot get it print when sales are MET/EXCEEDED(When all the total profit margin of the sales for all 4 quarters is greater than or equal to 20.
You should comment your if/else branches to describe the purpose of each branch.
Apologies, the part where I need help is on the "if else"
As I said, comments would help you to keep the logic straight AND to let someone else reading your code know what it is supposed to be doing. For example:
Assuming the comments I've added correspond to the logic you're trying to code, I believe you're missing the statement that goes with the last comment. Plus it seems the last else/if you have coded where the profitMargin is <=20 is inconsistent with the message that it's been a GOOD year. Did you get that condition backwards?// for less than a full year of sales data if(noOfQtrs < 4) { // if sales goals have been met if(profitMargin >= 20) { System.out.printf("\nKeep up the GOOD work and a possible year-end bonus!"); } // when sales goals have not been met else{ System.out.printf("\nSo far sales are lagging behind projections."); //PRINT3 } }//END IF(noOfQtrs <4) // for a full year of sales data and the sales goals have not been met else if(profitMargin <= 20) { System.out.printf("\nIt’s been a GOOD year. Thank you for all your hard work!\n" +"\nEmployees qualify for a 5% year end bonus!!!"); } //END IF // for a full year of sales data and the sales goals have been met System.exit(0);
yes I did get the last condition backwards. it was also supposed to be greater than or equal to. I edited it.
thank you for pointing that out, but it still won't print the printf statement for " System.out.printf("\nIt’s been a GOOD year. Thank you for all your hard work!\n"
+"\nEmployees qualify for a 5% year end bonus!!!");"
Please post the updated code.
To get to the print statement you've indicated (thanks for finally being specific), the first if() condition must be FALSE ( >= 4 ) and the corresponding else/if() statement must be TRUE. I believe you've changed this latter condition to:
else if ( profitMargin >= 20 )
If the print statement you want to print is never being executed, debug your code to find out why the first and latter conditions are never FALSE and TRUE, respectively, at the same time. Add print statements to output the values of the condition statement variables if you need to, but these statements are pretty basic, and you should be able to trace the results by inspection.