• 2021-04-14
    请写出与以下else-if语句等价的switch语句。
    if(choice == 1) price = 3.0;
    else if(choice == 2) price = 2.5;
    else if(choice == 3) price = 4.0;
    else if(choice == 4) price = 3.5;
    else{ price = 0.0; }
    switch
    {
    case 1: price=3.0; break;
    case 2: price=2.5; break;
    case 3:price=4.0;break;
    case 4: price=3.5;break;
    price=0.0; break;
    }