问答题

阅读以下应用说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。<br>【说明】<br>本应用程序的运行窗口如图2所示。<br>窗口中的3个文本框和两个按钮名称分别为Txt_salary、Txt_base、Txt_tax、Cmd_compute和Cmd_quit。运行时,文本框Txt_base存放的是免税金额基数(应扣除的基本费用co)当用户在文本框Txt_salary中输入月收入(工资或薪金)并单击“计算”按钮Cmd_compute后,Txt_tax框中就显示计算所得的应纳税额。文本框Txt_base和Txt_tax在运行时不接受用户输入,Txt_base的内容以灰色显示。<br>个人工资(或薪金)所得税是按照超额累进的税率来征收的,方法是:以每月收入总额减去免税金额基数后的余额作为该月的月应纳税所得额,再将应纳税所得额按相应级数采用相应的税率进行累进计算。目前的免税金额基数为800元,税率如表1所示。<br>设一个人的月应纳税所得额为K(元),用下面的公式计算其应缴纳的个人所得税额S (元);<br>若0<K≤500,则S=K×5%;<br>若500<K≤2000,则S=500×5%+(K-500)×10%;<br>若2000<K≤5000,则S=500×5%+1500×10%+(K-2000)×15%;<br>若5000<K≤20000,则S=500×5%+1500×10%+3000×15%+(K-5000)×20%;<br>例如,某人某月工资总额为4100元,减去800元后,应纳税所得额为3300元,其应缴纳的个人所得税额为500*5%+1500*10%+1300*15%=370元。<br>在开发过程中,需要编写的程序代码如下;<br>【程序】<br>Option Base 0<br>Private Sub Cmd_compute_Click()<br>Dim paylevel,taxPrate<br>paylevel = Array(0,500,2000,5000,20000,40000,60000,80000,100000, _1000001)<br>taxPrate = Array (5,10,15,20,25,30,35,40,45)<br>K=(1)<br>S=0<br>If(K>0) Then<br>For j = 1 To 9<br>If (2) Then<br>S = S + (paylevel(j) - paylevel(j -1) ) * taxPrate(j - 1)/100<br>Else<br>S=S+(3)*taxPrate(j-1)/100<br>Exit For<br>End If<br>Next j<br>Ent If<br>(4)=Str $(S)<br>End Sub<br>Private Sub Cmd_quit_Click()<br>End<br>End Sub<br>Private Sub Form_Load()<br>Txt_tax. Text =" "<br>Txt_salaw. Text =" "<br>Txt_base. Text = 800<br>Txt_tax. Locked = True<br>Txt_base. Enabled =(5)<br>End Sub


问答题

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。<br>[说明]<br>本程序使用类来管理员工的通讯地址信息。已知程序的输出为:<br>输出记录:5<br>姓名:王丽华<br>街道地址:中华路15号<br>市:襄樊市<br>省;湖北省<br>邮政编码:430070<br>[C++程序]<br>include < iostream, h ><br>include < string, h ><br>class employee.<br>{ protected:<br>char name[10];<br>char street[ 20 ];<br>char city[10];<br>char (1) [10];<br>char post[7];<br>int no;<br>(2):<br>(3) (char [] ,char [] ,char [] ,char [] ,char [] ,int);<br>void changename (char n [] ) { strcpy (name, n); }<br>void changestreet(char s[] ) { strcpy(street,s) ;}<br>void changecity (char c [] ) { strcpy (city, c ); }<br>void changeprov(char p [] ) { strcpy(prov,p); }<br>void changeno(int nnm) { (4);}<br>void display();<br>};<br>employee:: (3) (char n[] ,char s[] ,char c[] ,char p1[] ,char p2[] ,int nam)<br>{ strcpy(name,n);<br>strcpy (street, s);<br>strcpy (city, c);<br>strcpy (prov, p1 );<br>strcpy (post, p2 );<br>no = nam; }<br>void employee:: display() { cont< <"输出记录: "< <no< <endl;<br>cout< < "姓名: "< < name < < endl;<br>coot < < "街道地址: "< < street < < endl;<br>cout < < "市: "< < city < < endl;<br>cout< <"省: "< <prov < <endl;<br>cout < <"邮政编码: "< < post < < endl;<br>}<br>void main() { employee cmp("王华" ,"中华路15号" ,"武汉市","湖北省","430070", 1 );<br>emp. changename("五丽华" );<br>emp. changecity ("襄樊市" );<br>emp. changeno(5);<br>(5);


问答题

阅读以下说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。<br>[说明]<br>本程序提供了三阶矩阵加、减及乘运算的功能。用户单击“生成操作数”按钮将随机生成两个矩阵(即操作数1和操作数2),再单击某一矩阵运算按钮后,程序将输出相应运算的结果。程序运行界面如下:<br>开发过程中,界面上从左至右三个文本框分别取名为Text1至Text3,“生成操作数”按钮名为 CmdNew,“+”、“-”和“*”构成按钮控件组,分别名为CmdOperate(0)、CmdOperate(1)和CmdOperate(2)。<br>已知n阶矩阵加、减法运算法则是对应位置的元素相加、减;n阶矩阵的乘法C=AB有公式:Cij=AilBij+AilBij+…+An1Bnj其中记号Xij表示矩阵X第i行第j列上的元素。程序使用的主要变量是三维数组matrix(3,3,3),其元素matrix(i,j,k)代表第i个矩阵j行k列上的元素,这里i,j,k均从0开始计数,第0、1、2个矩阵分别表示操作数1、操作数2和结果矩阵。<br>代码中用到的子过程及其功能说明如下:<br>(1) Sub newMatrices():随机产生矩阵运算的两个操作数;<br>(2) Sub printOut(txt As TextBox, i As Integcr):定义矩阵i向文本框txt的输出格式;<br>(3) Sub operate(operation As String):计算并输出矩阵运算结果。<br>[Visual Basic代码]<br>Dim matrix(3, 3, 3) As Integer<br>Sub newMatrices()<br>……… End Sub<br>Sub printOut(txt As TextBox, i As Integer)<br>……… End Sub<br>Sub operate(operation As String)<br>Dim i, j, k As Integer<br>For i = 0 To 2<br>For j = 0 To 2<br>(1)<br>Case"+": matrix(2, i, j) = matrix(0, i, j) + matrix(1, i, j)<br>Case"-": matrix(2, i, j) = matrix(0, i, j) - matrix(1, i, j)<br>Case"*"<br>matrix(2, i, j) = 0<br>For k = 0 To 2<br>matrix(2, i, j) = matrix(2, i, j) +(2)<br>Next<br>End Select<br>Next<br>Next<br>printOut (3)<br>End Sub<br>Private Sub CmdNew_Cliek() ’“生成操作数”按钮的单击事件响应代码<br>(4)<br>printout Text1,0<br>printout Text2,1<br>End Sub<br>Private Sub CmdOperale_Click(Index As Integer) ’矩阵运算按钮组的单击事件响应代码<br>operate CmdOperate(Index).(5)<br>End Sub


问答题

阅读以下说明及C++程序代码,将应填入(n)处的语句写在对应栏内。<br>【说明】<br>本程序的功能是根据矩形左上角和右下角顶点坐标生成一个矩形对象,然后输出该矩形4个顶点的坐标,计算并输出该矩形的面积。<br>【C++代码】<br>include<iostream><br>using namespace std;<br>class MyPoint(//表示平面坐标系中的点的类<br>double x;<br>double y;<br>public:<br>MyPoint (double x,double y){this->x=x;this->y=y;}<br>double getX()const{(1);}<br>double getY()const{ return y;}<br>void show()const{ cout<<'('<<x<<','<<y<<')';}<br>};<br>class MyRectangle{ //表示矩形的类<br>MyPoint upleft; //矩形的左上角顶点<br>MyPoint down right; //矩形的右下角顶点<br>public:<br>MyRectangle(MyPoint upleft,MyPoint downright);<br>MyPoint getUpLeft()const{return up_left;} //返回左上角坐标<br>MyPoint getDownRight()const{return down_right;} //返回右下角坐标<br>MyPoint getUpRight()const; //返回右上角坐标<br>MyPoint getDownLeft()const; //返回左下角坐标<br>double area()const; //返回矩形的面积<br>};<br>MyRectangle:: MyRectangle((2)):<br>up left(p1),down_right(p2){}<br>MyPoint MyRectangle::getUpRight()const<br>{<br>return MyPoint(down_right.getX(),up_left.getY());<br>}<br>MyPoint MyRectangle::getDownLeft()const<br>{<br>return MyPeint((3));<br>}<br>double (4) ::area()const<br>{<br>return (getUpLeft(),getX()-getDownRight().getX())*<br>(getDownRight().getY()-getUpLeft().getY());<br>}<br>int main()<br>{<br>MyRectangle r(MyPoint(0,2),MyPoint(2,0));<br>r.getUpLeft(),show();<br>r.getUpRight().show();<br>r.getDown Right().show();<br>(5);<br>cout<<r.area()<<end1;<br>return 0;<br>}


火星搜题