#include <iostream>
using namespace std ;
int main() {
//Variables
char country;
int taxed ;
float pay ;
char uk_tax = 'a'; //40%
char us_tax ='b';//mulitple by number devide answer by 100
//Inputs
cout << "Enter your total earnings: ";
cin >> pay ;
cout << "Are you within the UK or USA?\n ";
cout << "a) For Uk b) For USA \n ";
cin >> country ;
switch(country)
{
case 1:
//chosen if input is a
if (country == uk_tax)
taxed = 40 * pay/100;
cout<< "Here are your earnings after Tax £" << taxed ;
break;
case 2:
//chosen if input is b
if (country == us_tax)
taxed = 28 * pay/100 ;
cout << "Here are your earning after Tax £" << taxed ;
break;
} return 0 }
你好我只是想知道是否有人可以幫助看到我與這段代碼有問題。代碼不執行開關語句。代碼它自己它只是兩個國家(美國,英國)的稅計算器用戶通過輸入'a'或'b'選擇國家,但我似乎無法得到它執行switch語句後執行switch語句?
也許是因爲'country'不是1或2? – immibis
案件是「a」和「b」不是「1」和「2」。 – NathanOliver
@NathanOliver:實際上是''a''和''b''。 –