我正在编写一个程序,该程序使用方法来获取用户输入的收入并输出他们所欠的所得税。
我在第 46 行有一个错误,即“私人双 GetTax(双税)” GetTax 是 CS0161 - 并非所有代码路径都返回一个值。
我错过了对 GetTax 的引用吗?非常感谢您的意见!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Lab_4_Part_2_
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnCalculate_Click(object sender, EventArgs e)
{
//Set input and output to floating decimal
double taxable = Convert.ToInt32(txtTaxable.Text);
GetTax(taxable);
}
private void EnterNum(double taxable)
{
throw new NotImplementedException();
}
private double GetTax(double taxable)
{
if (taxable <= 9225) return (taxable * 1.1);
if (taxable > 9225 | taxable < 37450) return (922.50 + (taxable * 1.15));
if (taxable > 37450 | taxable < 90750) return (5156.25 + (taxable * 1.25));
if (taxable > 90750 | taxable < 189300) return (18481.25 + (taxable * 1.28));
if (taxable > 189300 | taxable < 411500) return (46075.25 + (taxable * 1.33));
if (taxable > 411500 | taxable < 413200) return (119401.25 + taxable * 1.35);
if (taxable > 413200) return (119996.25 + (taxable * 1.396));
}
public string DisplayTaxable(double taxable)
{
return txtOwed.Text;
}
}
}