Using PromptforLetter and DisplayLetter in C# -


below homeowrk assignment i've been working on.

i need create class called formattedoutput in file called formattedoutput.cs. class have following methods: char promptforletter(void) - method return value void displayletter(char letter) - method accept value display

main should in file named mainmodule.cs main promptforletter each character in name , store each character char data type.

then displayletter(letter1) should display each letter as:

the actual letter decimal value of key hexadecimal value of key octal value of key binary value of key

information should displayed first... prompts each letter of name. table showing each value char decimal hex octal binary

here horrible mess have @ time

using system; using system.collections.generic; using system.linq; using system.text;  namespace consoleapplication1 {   public  class formattedoutput     {         char promptforletter(string prompt)         {             string value;              char achar;               console.writeline("a",  prompt);             console.writeline("l", prompt);             console.writeline("m", prompt);             console.writeline("a", prompt);             console.read();             value = console.readline();             achar=convert.tochar(value.substring(0,1));             return achar;         }          void displayletter (char letter)          {              console.writeline("a");             console.read(); 

i'm uncertain of you're going for, , might clear introduction problem (or instance, don't need know filenames , such, give relevant details). seems you're asking quite few questions, i'm going focus on think mean ask.

the impression i'm getting write console application in c#, method read single character user-input, 1 echo them using several number formats.

if is, in fact, case, want this:

public char promptforletter(string prompt) {     console.write(prompt + " "); // prints out prompt space, , no                                  // following line break      // have choice. should take first key pressed, or      // should user have press enter?      // option 1:     char ret = console.readkey().keychar;     console.writeline(); // not necessary, improves user experience     return ret;      // option 2:     return console.readline()[0]; // take first indexed character                                   // string entered user. strings have                                    // integer-indexers, can access single them                                   // characters in kind of if                                   // string array. } 

printing character bit simpler:

public void displayletter(char val) {     console.write("char: {0}", val);     console.write("decimal: {0}", (int)val);     console.write("hex: {0:x}", (int)val);     console.write("octal: {0}", convert.tostring((int)val, 8));     console.write("binary: {0}", convert.tostring((int)val, 2)); } 

beyond that, it's , instructor looking for, specifically.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -