{"id":6984,"date":"2014-05-16T01:18:35","date_gmt":"2014-05-16T01:18:35","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/16\/asks-the-user-for-an-angle-in-degrees-between-0-and-180-collection-of-common-programming-errors\/"},"modified":"2014-05-16T01:18:35","modified_gmt":"2014-05-16T01:18:35","slug":"asks-the-user-for-an-angle-in-degrees-between-0-and-180-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/16\/asks-the-user-for-an-angle-in-degrees-between-0-and-180-collection-of-common-programming-errors\/","title":{"rendered":"asks the user for an angle in degrees between 0 and 180-Collection of common programming errors"},"content":{"rendered":"<p>Put the question in a loop. When the user enters a value that is outside your range, print an error message and request a different value. When the entered value is OK, <em>then<\/em> you can exit the loop. It is better to use a function to make things more readable:<\/p>\n<pre><code>public static int askForInt(String question, String error, int min, int max) {\n    while (true) {\n       System.out.print(question + \" (an integer between \" + min + \" and \" + max + \"): \");\n       int read = new Scanner(System.in).nextInt();\n       if (read &gt;= min &amp;&amp; read<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Put the question in a loop. When the user enters a value that is outside your range, print an error message and request a different value. When the entered value is OK, then you can exit the loop. It is better to use a function to make things more readable: public static int askForInt(String question, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6984","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6984","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6984"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6984\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6984"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6984"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6984"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}