{"id":3024,"date":"2016-04-19T00:00:00","date_gmt":"2016-04-19T00:00:00","guid":{"rendered":"https:\/\/assignment.essayshark.com\/blog\/?p=3024"},"modified":"2022-01-12T12:19:26","modified_gmt":"2022-01-12T12:19:26","slug":"c-programming-examples-console-window-application","status":"publish","type":"post","link":"https:\/\/assignmentshark.com\/blog\/c-programming-examples-console-window-application\/","title":{"rendered":"C# Programming Examples: Console Window Application"},"content":{"rendered":"<h2>C# TASK:<\/h2>\n<p>Create a console window C# application that shows the following each time the Enter key is pressed:<\/p>\n<ol style=\"list-style-type: lower-alpha;\">\n<li style=\"list-style-type: none;\">\n<ol style=\"list-style-type: lower-alpha;\">\n<li style=\"list-style-type: none;\">\n<ol style=\"list-style-type: lower-alpha;\">\n<li>NUM LOCK key state (using green text on a blue background);<\/li>\n<li>CAPS LOCK key state (using red text on a yellow background);<\/li>\n<li>a request for a user to input a message (using default text and background colors) which is then set as the new titlebar text for the application.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p><!--more--><\/p>\n<h2>SOLUTION:<\/h2>\n<p>In this sample, we are going to inspect some of the more advanced functionalities when it comes to dealing with data exchange between the user and C# application through the console window. As you probably already know, this means that all the information comes in the form of text, with the user being expected either to make\/confirm choices, or input text data. To learn more ways to influence this, you may want to take a look at the properties and methods of .NET Framework&#8217;s Console Class itself: https:\/\/msdn.microsoft.com\/en-us\/library\/system.console%28v=vs.110%29.aspx<\/p>\n<p>Since the program is meant to work cyclically each time Enter is pressed (that is, each time the user inputs his or her message), we will need to use a looping statement. Let us also provide the user with the option to end it if he or she inputs the \u201cquit\u201d keyword. The basic looped code would look as follows:<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/1.png\" rel=\"attachment wp-att-3028\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3028\" style=\"max-width: 100%; height: auto;\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/1.png\" alt=\"Console window #1\" width=\"821\" height=\"343\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/1.png 821w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/1-300x125.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/1-768x321.png 768w\" sizes=\"auto, (max-width: 821px) 100vw, 821px\" \/><\/a><\/p>\n<p>Such an application will keep on prompting the user to enter a message until he or she inputs \u201cquit\u201d, after which the application will stop running. Next, let&#8217;s add the display of NUM LOCK and CAPS LOCK states into the loop. Since we can get their properties only as boolean true\/false, a little transition will be necessary to allow us to show their states as on\/off:<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/2.png\" rel=\"attachment wp-att-3036\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3036\" style=\"max-width: 100%; height: auto;\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/2.png\" alt=\"Console.NumberLock\" width=\"883\" height=\"486\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/2.png 883w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/2-300x165.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/2-768x423.png 768w\" sizes=\"auto, (max-width: 883px) 100vw, 883px\" \/><\/a><\/p>\n<p>Now we should upgrade the code with a text\/background color alteration, as well as the ability to update the titlebar on each loop:<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/3.png\" rel=\"attachment wp-att-3040\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3040\" style=\"max-width: 100%; height: auto;\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/3.png\" alt=\"Now we should upgrade the code with a text\/background color alteration, as well as the ability to update the titlebar on each loop\" width=\"883\" height=\"597\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/3.png 883w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/3-300x203.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/3-768x519.png 768w\" sizes=\"auto, (max-width: 883px) 100vw, 883px\" \/><\/a><\/p>\n<p>With this, the colors and the titlebar are updated; but the colors used for our CAPS LOCK-related message now also spreads to the subsequent messages when they shouldn&#8217;t. To fix this, we should reset them back to the defaults once the CAPS LOCK message ends:<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/4-1.png\" rel=\"attachment wp-att-3050\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3050\" style=\"max-width: 100%; height: auto;\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/4-1.png\" alt=\"\" width=\"883\" height=\"686\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/4-1.png 883w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/4-1-300x233.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/04\/4-1-768x597.png 768w\" sizes=\"auto, (max-width: 883px) 100vw, 883px\" \/><\/a><\/p>\n<p>This fixes the issue, and the application now works as it should.<\/p>\n<blockquote><p><em>This is one of our C# programming examples that was completed by our IT expert. You may be interested in our <a href=\"https:\/\/assignmentshark.com\/blog\/c-programming-sample-switch-case-operator\/\" target=\"_blank\" rel=\"noopener noreferrer\">C# programming sample on switch-case operator <\/a>as well. If you need any of technical assignments completed according to your requirements, don&#8217;t hesitate to contact us any time. Our experts will follow your requirements and will provide you with high-quality <a href=\"https:\/\/assignmentshark.com\/\" target=\"_blank\" rel=\"noopener\">assignment help<\/a>.<\/em><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>C# TASK: Create a console window C# application that shows the following each time the Enter key is pressed: NUM LOCK key state (using green text on a blue background); CAPS LOCK key state (using red text on a yellow background); a request for a user to input a message (using default text and background [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53,35],"tags":[],"class_list":["post-3024","post","type-post","status-publish","format-standard","hentry","category-it","category-samples"],"_links":{"self":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/3024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/comments?post=3024"}],"version-history":[{"count":15,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/3024\/revisions"}],"predecessor-version":[{"id":13089,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/3024\/revisions\/13089"}],"wp:attachment":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/media?parent=3024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/categories?post=3024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/tags?post=3024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}