Homework2CS480Q.1 WriteaJavaprogramthatfindsandprintsthesmallestintegerinthecommandlinearguments.Specifically,forthisprogram:

Homework2CS480Q.1 WriteaJavaprogramthatfindsandprintsthesmallestintegerinthecommandlinearguments.Specifically,forthisprogram:a)convertthecommandlineargumentstoanarrayofintegers,b)findthesmallestintegerinthearray,c)printtheresult.Yourprogramdoesnotneedtosortthearrayfirst.Instead,usethefollowingwell-known algorithm– whichismoreefficient:a) Assumethefirstelementinthearrayisthesmallestnumber(storethesmallestnumberinavariable)b) Foreachoftheremainingelementsinthearray,checktoseeifyouhaveasmallernumber(andifso,updateyoursmallestnumbervariable)Forexample,considerthefollowingprogramruns:C:jtesttest>javaFindMin101512817912Resultis:8C:jtesttest>javaFindMin40-515Resultis:-5Runyourprogram&PasteScreenshotsofprogramanditsoutput.Q.2WriteaprogramthatprintsaStringinthereverseorder.showsyouhowyoucantakeonequestionandmodifyittotestyourknowledgeofothertasks.WriteaprogramthatprintsaStringinthereverseorder.Algorithm:1. Startwithanemptystring“”calledreversedStr2. ForeachcharacterintheString(startwiththelastcharacterintheString),extractthe characterandappendittoreversedStr(useStringconcatenation)3. PrintreversedStrRunyourprogram&PasteScreenshotsofprogramanditsoutput.

Leave a Reply