纺织CAD实验指导书Word文档格式.docx

上传人:b****2 文档编号:15373396 上传时间:2022-10-29 格式:DOCX 页数:21 大小:26.12KB
下载 相关 举报
纺织CAD实验指导书Word文档格式.docx_第1页
第1页 / 共21页
纺织CAD实验指导书Word文档格式.docx_第2页
第2页 / 共21页
纺织CAD实验指导书Word文档格式.docx_第3页
第3页 / 共21页
纺织CAD实验指导书Word文档格式.docx_第4页
第4页 / 共21页
纺织CAD实验指导书Word文档格式.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

纺织CAD实验指导书Word文档格式.docx

《纺织CAD实验指导书Word文档格式.docx》由会员分享,可在线阅读,更多相关《纺织CAD实验指导书Word文档格式.docx(21页珍藏版)》请在冰豆网上搜索。

纺织CAD实验指导书Word文档格式.docx

pay:

=200;

overtimepay:

=300;

totalpay:

=pay+overtimepay;

Edit1.Text:

=IntToStr(totalpay);

7)双击Close按钮,在begin…end之间输入:

Close;

8)运行后(单击工具栏上的图标),按下start按钮。

Program2

Program1只使用了整数。

在Program2里,将整数变成实数,同时扣除税收,用两个组件分别表示总收入和净收入,并用标签显示组件的意义。

1)在Program1的基础上修改程序。

再选择一个Edit组件并放置在窗体上,其操作与Program1相同;

2)选两个Label标签放置于窗体上,并将其Caption属性分别设置为grosspayis和netpayis;

3)从Standard组件板选择两个Botton(按钮)组件置于窗体上,其Caption属性分别设置为“计算”和“关闭”;

4)Botton1的单击事件中的begin之前,var变量说明文的前一行,加入常量说明ConstTaxrate=0.075;

5)变量说明以及在begin…end之间输入以下语句

Const

Taxrate=0.075;

pay,overtimepay,grosspay,netpay:

single;

begin

pay:

=500.50;

pay:

=StrTofloat(gongzi.text);

=100.10;

Grosspay:

=pay+overtimepay;

netpay:

=grosspay-(grosspay*taxrate);

=FloatToStr(grosspay);

Edit2.Text:

=FloatToStr(netpay);

end;

5)运行程序。

三.实验报告要求:

1.在Program1里,将IntToStr()改为Format(‘Thetotalpayis%d‘,[totalpay]),观察其计算结果的表示方法的变化。

2.在Program2里,pay和overtimepay的值是在编写源代码时代入变量的,如果其变量值发生变化,就必须在程序中一一修改。

这里,用两个Edit组件,通过在它们的text属性里输入值来对变量pay和overtimepay进行赋值。

=Strtofloat(edit3.text);

formatfloat(‘0.00‘,grosspay);

可能用到的语句:

/////{限制键盘输入的必须是数字0~9和退格键,/////小数点,否则置空。

onkeypress事件中}

Ifnot(keyin[‘0’..’9’,’.’,#8])thenkey:

=#0;

{字符串相连运算}

Edit1.text:

=edit1.text+’2’;

=FloatToStr(strtofloat(edit1.text+’2’));

A:

=1

Ifa=1thenc+d

Ifa=2thenc-d

If判别式then

begin

**********************

end

else

********************

end;

caseaof

1:

c+d

2:

c-d

Case判别式of

限制式1:

begin语句end;

限制式2:

限制式3:

Elsebegin语句end;

{不是以上限制式时}

Forrepeatwhile

Integer,string,single,double,array,

Boolean。

IntTostr

FloatToStr《》StrToFloat

限制不能是空

ifedit1.Text='

'

thenshowmessage('

工资不能为空!

请输入数字'

=StrTofloat(edit1.text);

不要随意双击已经添加到窗体的组件。

实验二Pascal语言程序设计基础

一目的

Pascal语言程序设计基础训练。

理解Pascal程序格式,掌握整数、字符、记录等基本数据类型,熟练运用判断、循环等语句控制程序流程,熟悉基本组件Button,edit,label,ListBox,Memo,StringGrid等基本组件的使用方法。

二练习

要求:

将1到100的整数以不同形式显示出来。

(1)用for循环;

步骤

1.在Form上放置一个ListBox和两个Button组件;

2.双击Button1,在unit1代码编辑器的变量说明部分输入vari:

begin..end之间输入

fori:

=1to100do

ListBox1.items.Add(inttostr(i));

3.双击Button2,在unit1代码编辑器的变量说明部分输入vari:

ListBox1.items.Clear;

//清除内容

4.运行程序(单击run,button1andbutton2),观看其变化,ListBox的使用方法,for循环的意思。

(2)用repeatandwhile条件语句

1.在Form上放置一个Memo和两个Button组件;

i:

=1;

repeat

Memo1.lines.Add(inttostr(i));

=i+1;

Untili>

100;

Memo1.lines.Clear;

4.运行程序,单击run,button1andbutton2,观看其结果;

5.在Memo组件的ScrollBars属性(properties)里选择ssBoth;

单击lines属性右边的…,会出现stringlistseditor编辑框,消除memo1,单击ok,再运行,观察其变化。

如果i>

100改为i>

=100,会出现怎样的结果,为什麽?

6.自己用while和if条件语句做上述同样的练习。

要求:

制作一个学生清单,用记录数组数据类型和StringGrid组件.

1.在Form上放置一个stringGrid和Button组件;

2.双击Button1,在unit1代码编辑器的类型定义部分type加入

TstudentRecord=record

name:

string[20];

number:

integer;

telphone:

score:

end;

变量说明部分输入

student:

array[1..30]ofTstudentRecord;

i:

begin..end之间输入

student[1].name:

='

tangmeyun'

;

student[1].number:

=20010201;

student[1].telphone:

=68200101;

student[1].score:

=60.5;

student[2].name:

leibo'

student[2].number:

=20010202;

student[2].telphone:

=68200102;

student[2].score:

=65;

student[3].name:

xulipin'

student[3].number:

=20010203;

student[3].telphone:

=68200103;

student[3].score:

=85.4;

student[4].name:

zhangyuefen'

student[4].number:

=20010204;

student[4].telphone:

=68200104;

student[4].score:

=83.8;

=1to4do

StringGrid1.Cells[1,i]:

=student[i].name;

StringGrid1.Cells[2,i]:

=inttostr(student[i].number);

StringGrid1.Cells[3,i]:

=inttostr(student[i].telphone);

StringGrid1.Cells[4,i]:

=floattostr(student[i].score);

3.运行程序,观看其结果;

改变stringGrid组件的colcount和rowcount属性(properties)的值,观查表格的行列变化。

4.在StringGrid组件的第一行和第一列里分别加上行列意思的说明。

三实验报告要求

1.自定义格式输出edit1.Text:

=formatfloat('

0.00'

(2/3));

2.将0.1到0.9的数值用ListBox.items.add()、Memo.lines.add()和stringGrid.cells【i,j】:

=()表示出来;

3.增加注释说明的内容(至少5条)

参考语法:

StringGrid1.Cells[0,2]:

=‘学号’;

AA:

array[1..10]ofinteger;

//数组变量

B:

arrayofarrayofstring;

//数组申明

Repeat

语句1;

语句2:

***********

语句n;

Until结束条件;

While判断条件=truedo

Begin

语句1;

******

End;

Fori:

=计数初始值to计数结束值do

(或者Fori:

=计数初始值downto计数结束值do)

Try

语句2;

Except

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 纺织轻工业

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1