怎么编写一个简单Java应用程序,输出自己的姓名和学号?

如题所述

下面是一个java 小程序实现的
import java.awt.*;//引入包
import java.applet.Applet;//引入包
public class Output extends Applet//定义类
{
//定义变量
private String name;
private int num;
//初始化
public void init()
{
name = getParameter("vname");
num = Integer.parseInt(getParameter("vnum"));
}
//输出
public void paint(Graphics g)
{
g.drawString ("姓名:"+name+";学号:"+num,20,30);
}
}

相应的html文件
<html>
<applet code = "Output.class" height = 150 width = 300 >
<Param name = vname value = "姓名" >
<Param name = vnum value = 0012 >
</applet>
</html>
温馨提示:内容为网友见解,仅供参考
第1个回答  2013-10-29
下面是一个java 小程序实现的
import java.awt.*;//引入包
import java.applet.Applet;//引入包
public class Output extends Applet//定义类
{
//定义变量
private String name;
private int num;
//初始化
public void init()
{
name = getParameter("vname");
num = Integer.parseInt(getParameter("vnum"));
}
//输出
public void paint(Graphics g)
{
g.drawString ("姓名:"+name+";学号:"+num,20,30);
}
}

相应的html文件
<html>
<applet code = "Output.class" height = 150 width = 300 >
<Param name = vname value = "姓名" >
<Param name = vnum value = 0012 >
</applet>
</html>

怎么编写一个简单Java应用程序,输出自己的姓名和学号?
下面是一个java 小程序实现的\\x0d\\x0aimport java.awt.*;\/\/引入包\\x0d\\x0aimport java.applet.Applet;\/\/引入包\\x0d\\x0apublic class Output extends Applet\/\/定义类\\x0d\\x0a{\\x0d\\x0a \/\/定义变量\\x0d\\x0a private String name;\\x0d\\x0a private int num;\\x0d\\x0a \/\/...

...编写一个简单Java应用程序,输出自己的姓名和学号
} \/\/输出 public void paint(Graphics g){ g.drawString ("姓名:"+name+";学号:"+num,20,30);} } 相应的html文件 <Param name = vname value = "姓名" > <Param name = vnum value = 0012 >

编程输出学号和名字 java语言
public class Student{ public int xuehao; \/\/学号 public String name; \/\/姓名 \/\/输出方法 public void show(){ System.out.println("学号:"+this.xuehao+"\\n姓名:"+this.name); } public static void main(String[] args){ Student s = new Student(); ...

Java:学生信息姓名、学号、成绩。定义一个类,并定义相关的构造函数和方...
System.out.println("请输入第 " + (i + 1) + " 个学生信息:");try { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));System.out.println("姓名:");String name = reader.readLine();System.out.println("学号:");int id = Integer.parseInt(reader.readL...

JAVA编程 定义一个学生类,数据成员包括:学号,姓名,年龄,成绩;成员函数...
System.out.println("请输入第"+(i+1)+"个学生信息");System.out.println("学号:");String id = sca.nextLine();s.setId(id);System.out.println("姓名:");String name = sca.nextLine();s.setName(name);System.out.println("年龄:");int age = sca.nextInt();s.setAge(age);...

java输出学生学号,姓名,成绩
import java.util.ArrayList;import java.util.Random;public class Test { public static void main(String[] args) { ArrayList<Student> list = new ArrayList<Student>(); \/\/ 初始化成绩 for (int n = 0; n < 20; n++) { Student st = new Student(); st.setKemu1(new ...

用JAVA编写一个程序,要求如下:
import java.util.Scanner;public class StudentTest {public static void main(String[] args) {Student student = new Student();Scanner sc = new Scanner(System.in);System.out.println("请输入姓名:");student.setName(sc.next());System.out.println("请输入性别:");student.setSex(sc....

用java创建一个学生类,包括学号,姓名,成绩,然后构造方法,初始化,输出...
toString() {return "Name: " + name+ ",Number: " + number+ ",Score : " + score;}\/\/调用方法public static void main(String[] args) {Student s = new Student("Jack","123456",98);System.out.println(s.toString());}}运行结果:Name: Jack,Number: 123456,Score : 98 ...

用java定义学生类(学号、姓名、成绩)。用列表list存放班级学生信息...
import java.util.List;public class Admin { public static void main(String... args) { List data = new ArrayList();Student s0 = new Student();s0.setNo("000");s0.setName("a");s0.setChengji(100.0);data.add(s0);Student s1 = new Student();s1.setNo("001");s1.set...

Java编程题编写一个Java Application程序包含Person类、Student(学?
private String num;\/\/学号 private String school;\/\/学校 public void sayHello() { super.sayHello();System.out.println("学号:" + num);System.out.println("学校:" + school);} public Student(String num, String school) { this.num = num;this.school = school;} public Student(...

相似回答