• switch_goto


    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace switch_goto
    {
        
    class SwitchTest
        
    {
            
    static void Main()
            
    {
                Console.WriteLine(
    "Coffee sizes: 1=Small 2=Medium 3=Large");
                Console.Write(
    "Please enter your selection: ");
                
    string s = Console.ReadLine();
                
    int n = int.Parse(s);
                
    int cost = 0;
                
    switch (n)
                
    {
                    
    case 1:
                        cost 
    += 25;
                        
    break;
                    
    case 2:
                        cost 
    += 25;
                        
    goto case 1;
                    
    case 3:
                        cost 
    += 50;
                        
    goto case 1;
                    
    default:
                        Console.WriteLine(
    "Invalid selection.");
                        
    break;
                }

                
    if (cost != 0)
                
    {
                    Console.WriteLine(
    "Please insert {0} cents.", cost);
                }

                Console.WriteLine(
    "Thank you for your business.");
                Console.ReadLine();
            }

        }

    }
  • 相关阅读:
    Java之设计模式详解 (转)
    强引用,软引用,弱引用和虚引用总结
    Java基础知识总结
    深入理解Java的接口和抽象类
    Android Studio高级配置
    JS中innerHTML 和innerText和value的区别
    Prompt isNaN 数组 function DOM window.open/close/location/history
    WebForm组合查询
    WebForm分页浏览
    WebForm上传文件FileUpload
  • 原文地址:https://www.cnblogs.com/simhare/p/919841.html
Copyright © 2020-2023  润新知