{"id":4910,"date":"2022-08-25T02:37:19","date_gmt":"2022-08-24T21:07:19","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/"},"modified":"2022-08-25T02:37:19","modified_gmt":"2022-08-24T21:07:19","slug":"solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/","title":{"rendered":"[Solved] how to solve my errors in my code about online test to be like in the pdf file? [closed]"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-49949517\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"49949517\" data-parentid=\"49948779\" data-score=\"0\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<h3>Hi!This is your code without errors!<\/h3>\n<p>So, I changed somethings, I&#8217;ll list them to get clearer.<\/p>\n<ol>\n<li>To use &#8220;Name&#8221; and &#8220;Id&#8221; in more than one method, it is easier if they are global variables.<\/li>\n<li>When calling the &#8220;test&#8221; method you need to pass the values, so in the &#8220;entry&#8221; method the values are passed.<\/li>\n<li>The &#8220;printData&#8221; method is called within &#8220;results&#8221; to receive the value of &#8220;totalScores&#8221;<\/li>\n<li>Also in the &#8220;results&#8221; method to calculate the value of &#8220;percentage&#8221; you must divide by the number of scores, which in this case is 3<\/li>\n<li>\n<p>The methods need to be static, just the test method. In the test method, a class must be instantiated to test the class itself.<\/p>\n<pre><code>import java.util.Scanner;\n\npublic class OnlineTest {       \nString name;\ndouble id;\n\npublic void entry() {\n    Scanner input = new Scanner(System.in);\n    System.out.println(\"Please, Enter Your  Full Name :\");\n    name = input.nextLine();\n    System.out.println(\"Please, Enter your Test Registration ID :\");\n    id = input.nextDouble();\n\n    System.out.println(\" . . . Starting Test\\n\");\n\n    test(0, 0, 0);\n}\n\npublic void test(double score1, double score2, double score3) {\n    String answer;\n    Scanner input = new Scanner(System.in);\n\n    System.out.println(\"- Choose the Correct Answer:\\n\");\n\n    do {\n        System.out.println(\"a. Which Utility is used to compile Java applications?\\n\" + \"   1. javaw\\n\"\n                + \"   2. java\\n\" + \"   3. javac \");\n        answer = input.next();\n    } while (!answer.equals(\"1\") &amp;&amp; !answer.equals(\"2\") &amp;&amp; !answer.equals(\"3\"));\n\n    if (answer.equals(\"3\")) {\n        score1 = 100;\n    } else if (!answer.equals(\"3\")) {\n        score1 = 0;\n    }\n\n    do {\n        System.out.println(\n                \"b. Which is a restriction when using a switch statement? \\n\" + \"   1. Characters cannot be used\\n\"\n                        + \"   2. Doubles cannot be used\\n\" + \"   3. Integers can not be used\");\n        answer = input.next();\n    } while (!answer.equals(\"1\") &amp;&amp; !answer.equals(\"2\") &amp;&amp; !answer.equals(\"3\"));\n\n    if (answer.equals(\"1\")) {\n        score2 = 100;\n    } else if (!answer.equals(\"1\")) {\n        score2 = 0;\n    }\n\n    do {\n        System.out.println(\"c. What is the range of byte data type in Java?  \\n\" + \"   1. -128 to 127\\n\"\n                + \"   2. -32768 to 32767\\n\" + \"   3. -2147483648 to 2147483647\");\n        answer = input.next();\n    } while (!answer.equals(\"1\") &amp;&amp; !answer.equals(\"2\") &amp;&amp; !answer.equals(\"3\"));\n\n    if (answer.equals(\"1\")) {\n        score3 = 100;\n    } else if (!answer.equals(\"1\")) {\n        score3 = 0;\n    }\n\n    double totalscores = score1 + score2 + score3;\n    results(totalscores);\n\n}\n\npublic void results(double totalscores) {\n\n    double percentage = (totalscores) \/ 3;\n    printData(percentage);\n}\n\npublic void printData(double percentage) {\n\n    System.out.println(\"-----------------------\");\n\n    System.out.println(\"\\tJava Certification\\n\" + \"\\t   Test Results\\n\");\n\n    System.out.println(\"Name : \" + name);\n    System.out.println(\"Test Registration ID:\" + id);\n\n    System.out.println(\"Passing Score 52% \");\n    System.out.println(\"Your Score : \" + percentage + \"% \\n\");\n\n    System.out.println(\"Max Score --------------------100%\\r\\n\" + \"Passing Score -----------52\");\n\n}\n\npublic static void main(String[] args) {\n    OnlineTest onlineTest = new OnlineTest();\n    onlineTest.entry();\n\n}\n}\n<\/code><\/pre>\n<\/li>\n<\/ol><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">2<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved how to solve my errors in my code about online test to be like in the pdf file? [closed] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Hi!This is your code without errors! So, I changed somethings, I&#8217;ll list them to get clearer. To use &#8220;Name&#8221; and &#8220;Id&#8221; in more than one method, it is easier if they are global variables. When calling the &#8220;test&#8221; method you need to pass the values, so in the &#8220;entry&#8221; method the values are passed. &#8230; <a title=\"[Solved] how to solve my errors in my code about online test to be like in the pdf file? [closed]\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/\" aria-label=\"More on [Solved] how to solve my errors in my code about online test to be like in the pdf file? [closed]\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[573,323],"class_list":["post-4910","post","type-post","status-publish","format-standard","hentry","category-solved","tag-eclipse","tag-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] how to solve my errors in my code about online test to be like in the pdf file? [closed] - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] how to solve my errors in my code about online test to be like in the pdf file? [closed] - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] Hi!This is your code without errors! So, I changed somethings, I&#8217;ll list them to get clearer. To use &#8220;Name&#8221; and &#8220;Id&#8221; in more than one method, it is easier if they are global variables. When calling the &#8220;test&#8221; method you need to pass the values, so in the &#8220;entry&#8221; method the values are passed. ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-24T21:07:19+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] how to solve my errors in my code about online test to be like in the pdf file? [closed]\",\"datePublished\":\"2022-08-24T21:07:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/\"},\"wordCount\":159,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"eclipse\",\"java\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/\",\"name\":\"[Solved] how to solve my errors in my code about online test to be like in the pdf file? [closed] - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-08-24T21:07:19+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] how to solve my errors in my code about online test to be like in the pdf file? [closed]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] how to solve my errors in my code about online test to be like in the pdf file? [closed] - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] how to solve my errors in my code about online test to be like in the pdf file? [closed] - JassWeb","og_description":"[ad_1] Hi!This is your code without errors! So, I changed somethings, I&#8217;ll list them to get clearer. To use &#8220;Name&#8221; and &#8220;Id&#8221; in more than one method, it is easier if they are global variables. When calling the &#8220;test&#8221; method you need to pass the values, so in the &#8220;entry&#8221; method the values are passed. ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/","og_site_name":"JassWeb","article_published_time":"2022-08-24T21:07:19+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] how to solve my errors in my code about online test to be like in the pdf file? [closed]","datePublished":"2022-08-24T21:07:19+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/"},"wordCount":159,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["eclipse","java"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/","url":"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/","name":"[Solved] how to solve my errors in my code about online test to be like in the pdf file? [closed] - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-08-24T21:07:19+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-solve-my-errors-in-my-code-about-online-test-to-be-like-in-the-pdf-file-closed\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] how to solve my errors in my code about online test to be like in the pdf file? [closed]"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/4910","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=4910"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/4910\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=4910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=4910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=4910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}