The finished C# statement Help system that processes multiple requests : for « Language Basics « C# / C Sharp






The finished C# statement Help system that processes multiple requests

The finished C# statement Help system   
   that processes multiple requests
/*
C# A Beginner's Guide
By Schildt

Publisher: Osborne McGraw-Hill
ISBN: 0072133295
*/
/*  
   Project 3-3  
  
   The finished C# statement Help system   
   that processes multiple requests.  
*/  
  
using System;  
  
public class Help3 {  
  public static void Main() {  
    char choice;  
  
    for(;;) {  
      do {  
        Console.WriteLine("Help on:");  
        Console.WriteLine("  1. if");  
        Console.WriteLine("  2. switch");  
        Console.WriteLine("  3. for");  
        Console.WriteLine("  4. while");  
        Console.WriteLine("  5. do-while");  
        Console.WriteLine("  6. break");  
        Console.WriteLine("  7. continue");  
        Console.WriteLine("  8. goto\n");  
        Console.Write("Choose one (q to quit): ");  
        do {  
          choice = (char) Console.Read();  
        } while(choice == '\n' | choice == '\r');      
      } while( choice < '1' | choice > '8' & choice != 'q');  
  
      if(choice == 'q') break;  
  
      Console.WriteLine("\n");  
   
      switch(choice) {  
        case '1':  
          Console.WriteLine("The if:\n");  
          Console.WriteLine("if(condition) statement;");  
          Console.WriteLine("else statement;");  
          break;  
        case '2':  
          Console.WriteLine("The switch:\n");  
          Console.WriteLine("switch(expression) {");  
          Console.WriteLine("  case constant:");  
          Console.WriteLine("    statement sequence");  
          Console.WriteLine("    break;");  
          Console.WriteLine("  // ...");  
          Console.WriteLine("}");  
          break;  
        case '3':  
          Console.WriteLine("The for:\n");  
          Console.Write("for(init; condition; iteration)");  
          Console.WriteLine(" statement;");  
          break;  
        case '4':  
          Console.WriteLine("The while:\n");  
          Console.WriteLine("while(condition) statement;");  
          break;  
        case '5':  
          Console.WriteLine("The do-while:\n");  
          Console.WriteLine("do {");  
          Console.WriteLine("  statement;");  
          Console.WriteLine("} while (condition);");  
          break;  
        case '6':  
          Console.WriteLine("The break:\n");  
          Console.WriteLine("break;");  
          break;  
        case '7':  
          Console.WriteLine("The continue:\n");  
          Console.WriteLine("continue;");  
          break;  
        case '8':  
          Console.WriteLine("The goto:\n");  
          Console.WriteLine("goto label;");  
          break;  
      }  
      Console.WriteLine();  
    }  
  }  
}



           
       








Related examples in the same category

1.Simplest forSimplest for
2.For loop for array
3.Determine smallest single-digit factorDetermine smallest single-digit factor
4.A negatively running for loopA negatively running for loop
5.Determine if a number is prime. If it is not, then display its largest factorDetermine if a number is prime.  If it is not, 
   then display its largest factor
6.loop with letter char as the control variable
7.Use commas in a for statememtUse commas in a for statememt
8.Use commas in a for statememt to find the largest and smallest factor of a numberUse commas in a for statememt to find 
   the largest and smallest factor of a number
9.Loop condition can be any bool expressionLoop condition can be any bool expression
10.Parts of the for can be emptyParts of the for can be empty
11.Move more out of the for loopMove more out of the for loop
12.The body of a loop can be emptyThe body of a loop can be empty
13.Declare loop control variable inside the forDeclare loop control variable inside the for
14.Using break to exit a loopUsing break to exit a loop
15.Use continueUse continue
16.Demonstrate the for loopDemonstrate the for loop
17.Compute the sum and product of the numbers from 1 to 10. Compute the sum and product of the numbers from 1 to 10.
18.For Loop TesterFor Loop Tester
19.If inside a forIf inside a for
20.For without init valueFor without init value
21.For without increaseFor without increase
22.For with empty conditionFor with empty condition
23.a for loop to display 1 to 5a for loop to display 1 to 5
24.Update two parameters in for loop