zoukankan      html  css  js  c++  java
  • do while循环学习

    下面是一个实例:实现DO....While和switch..case

    using System;
    class Doloop
    {
    public static void Main()
    {
    string myChoice;
    do {
    // Print A Menu
    Console.WriteLine("My Address Book\n");
    Console.WriteLine("A - Add New Address");
    Console.WriteLine("D - Delete Address");
    Console.WriteLine("M - Modify Address");
    Console.WriteLine("V - View Addresses");
    Console.WriteLine("Q - Quit\n");
    Console.WriteLine("Choice (A,D,M,V,or Q): ");

    // Retrieve the user's choice
    myChoice = Console.ReadLine();
    // Make a decision based on the user's choice
    switch(myChoice)
    {
    case "A":
    case "a":
    Console.WriteLine("You wish to add an address.");
    break;
    case "D":
    case "d":
    Console.WriteLine("You wish to delete an address.");
    break;
    case "M":
    case "m":
    Console.WriteLine("You wish to modify an address.");
    break;
    case "V":
    case "v":
    Console.WriteLine("You wish to view the address list.");
    break;
    case "Q":
    case "q":
    Console.WriteLine("Bye.");
    break;
    default:
    Console.WriteLine("{0} is not a valid choice", myChoice);
    break;
    }

    // Pause to allow the user to see the results
    Console.Write("Press any key to continue...");
    Console.ReadLine();
    Console.WriteLine();
    } while (myChoice != "Q" && myChoice != "q"); // Keep going until the user wants to quit
    }
    }

  • 相关阅读:
    UILabel的使用
    CGAffineTransform的使用
    UIView的常用方法
    UICollectionViewController的用法1
    网址连接
    android developers blog
    Java并发编程:volatile关键字解析
    Android触摸屏事件派发机制详解与源码分析
    setScale,preScale 和 postScale 的区别
    android 内存
  • 原文地址:https://www.cnblogs.com/lzlcn/p/1304674.html
Copyright © 2011-2022 走看看