小编The*_*ete的帖子

c++ default not working in switch statement

Fairly new to programming here. I can't get my default code in the switch statement to work. I want it to display an error and exit as soon as any data input that's not in the range is entered. For some reason, it goes to the next cout line after the switch statement.

#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
char choice;
const double P=8.00, A=10.50, B=12.50;
double t,w,price;

cout<<"\nPlease enter the state code: "; …
Run Code Online (Sandbox Code Playgroud)

c++ switch-statement

3
推荐指数
1
解决办法
89
查看次数

标签 统计

c++ ×1

switch-statement ×1