1、体型判断
某体检中心按照“体重指数”对客户的体形进行判断,体重指数计算如下:
体重指数t=体重w/ (身高h^2)(w单位:公斤;h单位:米)
判断依据:当t < 18 时,体型为“偏瘦”;当t介于18和25之间时,体型为“正常”;当t介于25和27之间时,体型为“超重”;当t >=27时,体型为“肥胖”。要求:编程从键盘输入你的身高h和体重w,根据给定公式计算体重指数t,然后判断你的体重属于何种类型。
*体型判断
*PARAMETERS:
* W TYPE STRING,
* H TYPE STRING.
*
*DATA T TYPE STRING.
*
*T = W / ( H * H ).
* WRITE:/ '您的T值为:',T.
*
*IF T < '18'.
* WRITE:/ '您的体型为“偏瘦”'.
* ENDIF.
* IF T > '18'.
* IF T < '25'.
* WRITE:/ '您的体型为“正常”'.
* ENDIF.
* ENDIF.
* IF T > '25'.
* IF T < '27'.
* WRITE:/ '您的体型为“超重”'.
* ELSE.
* WRITE:/ '您的体型为“肥胖”'.
* ENDIF.
* ENDIF.
2、身高预测
每个人的身高与遗传、饮食习惯与体育锻炼等因素密切相关。设faHeight为父亲身高,moHeight为母亲身高,身高预测公式为:男性成人时身高=(faHeight + moHeight)×0.54cmcm女性成人时身高=(faHeight×0.923 + moHeight)/2cm。此外,如果喜爱体育锻炼,那么可增加身高2%;如果有良好的卫生饮食习惯,那么可增加身高1.5%。
编程:从键盘输入用户的性别、父母身高、是否喜爱体育锻炼、是否有良好的饮食习惯等条件,利用给定公式和身高预测方法对身高进行预测。
*身高预测
*PARAMETERS:
* SEX TYPE STRING,
* faHeight TYPE I,
* moHeight TYPE I,
* PE TYPE STRING,
* GH TYPE STRING.
*
*DATA: M_HEIGHT TYPE I ,
* M_HEIGHT1 TYPE I,
* M_HEIGHT2 TYPE I,
* M_HEIGHT3 TYPE I,
* W_HEIGHT TYPE I,
* W_HEIGHT1 TYPE I,
* W_HEIGHT2 TYPE I,
* W_HEIGHT3 TYPE I.
*
*M_HEIGHT = ( faHeight + moHeight ) * '0.54'.
*M_HEIGHT1 = M_HEIGHT * ( 1 + '0.015' ).
*M_HEIGHT2 = M_HEIGHT * ( 1 + '0.02' ).
*M_HEIGHT3 = M_HEIGHT * ( 1 + '0.035' ).
*
*W_HEIGHT = ( faHeight * '0.923' + moHeight ) / 2.
*W_HEIGHT1 = W_HEIGHT * ( 1 + '0.015' ).
*W_HEIGHT2 = W_HEIGHT * ( 1 + '0.02' ).
*W_HEIGHT3 = W_HEIGHT * ( 1 + '0.035' ).
*
*IF SEX = '女'.
* IF PE = '否'.
* IF GH = '否'.
* WRITE:/ '你的预测身高为:',W_HEIGHT.
* ELSEIF GH = '否'.
* WRITE:/ '你的预测身高为:',W_HEIGHT1.
* ENDIF.
* ELSEIF PE = '是'.
* IF GH = '是'.
* WRITE:/ '你的预测身高为:',W_HEIGHT3.
* ELSEIF GH = '否'.
* WRITE:/ '你的预测身高为',W_HEIGHT2.
* ENDIF.
* ENDIF.
*ENDIF.
*
*IF SEX = '男'.
* IF PE = '否'.
* IF GH = '否'.
* WRITE:/ '你的预测身高为:',M_HEIGHT.
* ELSEIF GH = '是'.
* WRITE:/ '你的预测身高为:',M_HEIGHT1.
* ENDIF.
* ELSEIF PE = '是'.
* IF GH = '是'.
* WRITE:/ '你的预测身高为:',M_HEIGHT3.
* ELSEIF GH = '否'.
* WRITE:/ '你的预测身高为',M_HEIGHT2.
* ENDIF.
* ENDIF.
*ENDIF.
3、出租车计费问题。计费标准如下:起步价为5元,前2公里不计费;超过2公里但不超过10公里,按单程1.6元/公里计费;10公里以上,一律按单程1元/公里计费。实际行驶里程四舍五入取整后作为计算里程。请为出租车司机编写程序,当输入实际里程时,立即输出乘客应付的车费。
* 出租车计费问题
*PARAMETERS:
* S TYPE I.
*DATA: M TYPE I,
* M1 TYPE I,
* M2 TYPE I.
*
*M = 5.
*M1 = M + ( S - 2 ) * '1.6'.
*M2 = M + ( S - 2 ) * 1.
*
*IF S <= 2.
* WRITE:/ '应付车费为:',M.
*ELSE.
* IF S < 10.
* WRITE:/ '应付车费为:',M1.
* ENDIF.
* IF S > 10.
* WRITE:/ '应付车费为:',M2.
* ENDIF.
*ENDIF.
4、判断天数。
输入某年某月某日,判断这一天是这一年的第几天?
* 判断天数
PARAMETERS:
DAY TYPE I,
MONTH TYPE I,
YEAR TYPE I.
DATA:
DAYS TYPE I.
IF YEAR MOD 400 = 0 OR ( YEAR MOD 4 = 0 AND YEAR MOD 100 <> 0 ).
CASE MONTH.
WHEN 1.
DAYS = DAY.
WHEN 2.
DAYS = 31 + DAY.
WHEN 3.
DAYS = 31 + 29 + DAY.
WHEN 4.
DAYS = 31 + 29 + 31 + DAY.
WHEN 5.
DAYS = 31 + 29 + 31 + 30 + DAY.
WHEN 6.
DAYS = 31 + 29 + 31 + 30 + 31 + DAY.
WHEN 7.
DAYS = 31 + 29 + 31 + 30 + 31 + 30 + DAY.
WHEN 8.
DAYS = 31 + 29 + 31 + 30 + 31 + 30 + 31 + DAY.
WHEN 9.
DAYS = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + DAY.
WHEN 10.
DAYS = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + DAY.
WHEN 11.
DAYS = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + DAY.
WHEN 12.
DAYS = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + DAY.
ENDCASE.
ELSE.
CASE MONTH.
WHEN 1.
DAYS = DAY.
WHEN 2.
DAYS = 31 + DAY.
WHEN 3.
DAYS = 31 + 28 + DAY.
WHEN 4.
DAYS = 31 + 28 + 31 + DAY.
WHEN 5.
DAYS = 31 + 28 + 31 + 30 + DAY.
WHEN 6.
DAYS = 31 + 28 + 31 + 30 + 31 + DAY.
WHEN 7.
DAYS = 31 + 28 + 31 + 30 + 31 + 30 + DAY.
WHEN 8.
DAYS = 31 + 28 + 31 + 30 + 31 + 30 + 31 + DAY.
WHEN 9.
DAYS = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + DAY.
WHEN 10.
DAYS = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + DAY.
WHEN 11.
DAYS = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + DAY.
WHEN 12.
DAYS = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + DAY.
ENDCASE.
ENDIF.
WRITE:/ YEAR,'年',MONTH,'月',DAY,'天','是',YEAR,'的第',DAYS,'天'.
5、判断回文一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同。
* DAYS = DAYS + DAY.
*WRITE:/ DAYS.
* 判断回文
*PARAMETERS: NUM TYPE STRING.
*
*DATA: A TYPE I,
* B TYPE I,
* C TYPE I,
* D TYPE I.
*
*A = NUM+0(1).
*B = NUM+1(1).
*C = NUM+3(1).
*D = NUM+4(1).
*
*IF A = D AND B = C.
* WRITE:/ NUM,'是回文数'.
*ELSE.
* WRITE:/ NUM,'不是回文数'.
*ENDIF.