- 博客(4)
- 收藏
- 关注
原创 定义一个类,为该类定义三个构造函数,分别执行以下操作:1传递一个char型的字符并输出其Unicode编码值,2传递两个float型的数并输出其中较小的数;3传递三个int型的数并输乘积数值
class shun { shun(char ch) { int i = ch; System.out.println(i); } shun(float d,float e){ if (d>e){ System.out.println(e); }else { System.out.println(d); } } shun(int a,.
2021-10-26 22:39:47
707
原创 3、定义一个Number类,包含两个整型的成员变量n1和n2,编写构造函数初始化n1、n2的值;再定义四个实现加、减、乘、除运算功能的成员函数,分别对n1和n2执行加、减、乘、除(分别输出商和余数)的
public class text3{ public static void main(String[] args) { Number shun = new Number(10,4); shun.add(); shun.minus(); shun.cheng(); shun.chu(); }} class Number{ int n1,n2; int sum,sum1; publi.
2021-10-26 22:33:21
2057
原创 Java使用循环结构计算1到10这10个整数的阶乘和。
public class text2 { public static void main(String[] args){ int i=1,t=1,sum=0,a=1; for (i=1;i<=10;i++){ for (t=1;t<=i;t++) { a = a* t; } sum=a+sum; } System.
2021-10-26 22:27:38
4323
原创 使用选择结构实现如下数学分段函数的功能。要求:(1)设x为整数,其值由用户通过小窗口的形式进行输入;(2)根据所输入的x值,打印输出其分段函数中对应y的值。
public class text1 { public static void main(String[] args) { String strx = javax.swing.JOptionPane.showInputDialog("输入数值"); int x = Integer.parseInt(strx); if (x < 0) { x=0; } else if (x < 10) { .
2021-10-26 22:26:17
908
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅