Loops

admin

Administrator
Staff member
Does anybody know where to find how to use For...Next loop in java, I've searchfor a while, but it seem "Next" is not used at all.will you please advice, it's a school assignment. It's looks easy, but theconditionQ2: This question is to give experience in using the "for ... next" loopand in using methods. You are to write a short program which:Accepts two integers from the command line when the program is run.Echoes those two integers to the display.Displays the sum of the two integers plus all the integers between them.For example, if the input were 10 and 12, the sum would be 10 + 11 + 12 =33.The calculation of the sum should be done, using a "for ... next" loop, bya method outside main. Suggestion: get the program to work with only mainfirst, then change it. You should also ensure that the program accepts afirst input integer which is larger than the second. In other words, theprogram should accept the input "...(program name) .... 20 10" as well as"...(program name) .... 10 20".Submit the source file as well as output for several runs. Include in yoursample run the input integer pairs 1 & 100 ; -20 & -10; -15 & 15, 20 & -20,15 & 5, -12 & -40. To save paper, paste the output files together into onedocument before printing. Be sure to document your submission.
 
Top