常用十题
1、九九乘法表:
public class chengfa {
public static void main(String[] args) {
int i,j;
System.out.println("9*9    乘法表如下:    ");
for(i=1;i<=9;i++)
{
java经典上机编程题for(j=1;j<=i;j++)
{
System.out.print(+i+"*"+j+"="+i*j);
System.out.print(" " );
}
System.out.println( );
}
}
}
2、成绩判断
import java.util.Scanner;
public class chengjipanduan {
public static void main(String[] args) {
int grade;
System.out.println(" 输入你的成绩:    ");
Scanner s=new Scanner(System.in);
Int();
switch(grade/10)
{
case 10:
case 9:
System.out.println(" 你的成绩为优    ");break;
case 8:
System.out.println(" 你的成绩为良    ");break;
case 7:

System.out.println(" 你的成绩为中    ");break;
case 6:
System.out.println(" 你的成绩为及格    ");break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
System.out.println(" js write函数你的成绩为差    ");break;
}
}
}
3、矩形类
public class Rectangle {
double width=1.0;
double height=1.0;
public Rectangle(double width,double height)
{
this.width=width;
this.height=height;
}
public void setwidth(double width)
{
this.width=width;
}
public double getwidth(double widtht)
{
return width;
}
public void setheight(double height)
简单大气的花边边框{
this.height=height;
}
public double getheight(double height)
{
return height;
}

public double getArea()
{
return width*height;
}
public double getperimeter()
{
return 2*(width+height);
}
}
import tixing06.Rectangle;
public class TestRectangle {
public static void main(String[] args)
{
Rectangle r=new Rectangle(4,40);
System.out.println(" 矩形面积为  "+r.getArea()+" 周长为 "+r.getperimeter());
}
}
4、两数对换
package tixing;
import java.util.Scanner;
public class TiXing02 {
public static void main(String[] args) {
int a,b;
System.out.println(" 输入两个数    a b:");
汇编求补指令Scanner s=new Scanner(System.in);
Int();
Scanner k=new Scanner(System.in);
Int();
System.out.println(" 两个数为 :a="+a+"    b="+b    );

exchange(a,b);

}
public static void exchange(int a,int b)
{
int t;
t=a;a=b;b=t;
System.out.println(" 交换后两个数为snapshotrepository    :a="+a +" b="+b    );
}
}
5、数组
import java.util.Scanner;
import java.util.Random;
public class shuzu {
public static void main(String[] args) {
int n,i,j,k;
double ave=0;
System.out.println(" 输入数组长度:    ");
Scanner s=new Scanner(System.in);
Int();
int a[]=new int[n];
System.out.println(" 输入的原数组为:    ");
for(i=0;i<n;i++)
{
a[i]=(int)(Math.random()*10+1);
System.out.printf("%4d",a[i]);
}
for(i=0;i<n;i++) {
for(j=i+1;j<n;j++)
{
if(a[j]>a[i])
{
k=a[i];a[i]=a[j];a[j]=k;
}
}

databasename是什么

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。