用java写一个小程序

用java写一个小程序,第1张

java实现先输入10个int类型的参数,之后循环判断找到最大值和最小值,保存起来和其他的值进行比较。代码如下:

public class Test{

public static void main(String args[]){

int i,min,max

int A[] = new int[10]

Scanner input=new Scanner(System.in)

for(int j=0,j<10j++){//输入10个数

System.out.println("请输入一个数字:")

int length=input.nextInt()//输入一个数字

A[i] =length

}

min=max=A[0]

System.out.print("数组A的元素包括早判:")

int j =0

int n =0

for(i=0i<A.lengthi++)

{

System.out.print(A[i]+" ")

if(A[i]>max) // 判断最大值

j =i

max=A[i]

if(A[i]<min) // 判断最小值

min=A[i]

n =i

}

System.out.println("\n数组的最大值是:"+max+".数组的位置是:"+(j+1))// 输出最大值和最大值的位如帆置

System.out.println("数组的最小值是:"+min+".数组的位置是:"陆橡改+(n+1))// 输出最小值

}

}

Java不能设计微信小程序,微信小程序开发有其自己的语猜孙言和文件形式。滚猛Java可以作为微信小程序的服务端语言和api接口服务器语言为小程序端提供服务,而不是大兆桥直接开发微信小程序。

package t

import java.awt.Button

import java.awt.Frame

import java.awt.Label

import java.awt.Panel

import java.awt.TextField

public class UI extends Frame {

public UI() {

super("登录界面")

Panel p = new Panel()

p.setLayout(null)

Label l1=new Label("用户名")

l1.setBounds(20,20, 100,30)

Label l2=new Label("密码"模宏)

l2.setBounds(20,55, 100,30)

TextField t1=new TextField()

t1.setBounds(120,20, 100,20)

TextField t2=new TextField()

t2.setBounds(120,55, 100,20)

Button enter = new Button("确定"闷码巧)

enter.setBounds(100,90, 50,30)

Button help = new Button("取蚂键消")

help.setBounds(160,90, 50,30)

p.add(l1)

p.add(l2)

p.add(t1)

p.add(t2)

p.add(enter)

p.add(help)

p.setBounds(0,0,200,200)

this.add(p)

this.setBounds(100,100,300,200)

this.setVisible(true)

}

public static void main(String args[]) {

new UI()

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12472259.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存