Java编程代码示例,java编程例子-成都快上网建站

Java编程代码示例,java编程例子

一个简单的Java程序代码?

package com.zpp;public class Charge {

创新互联从2013年成立,先为罗湖等服务建站,罗湖等地企业,进行企业商务咨询服务。为罗湖企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

public static void main(String [] args) {

if(args.length ==0) {

System.out.println("parameter error!");

System.out.println("java com.zpp.Charge [int]");

return;

}

int min = Integer.parseInt(args[0]);

double money = 0.0;

if (min = 0) {

money =0.0;

System.out.println("not money");

} else if (min = 60) {

money = 2.0;

} else {

money = 2.0 + (min - 60) * 0.01;

}

System.out.println("please pay: " + money);

}

} 编译:javac -d . Charge.java运行:java com.zpp.Charge 111

Java编程(写出程序代码)

import java.util.Scanner;

/*输入一个成绩,将该成绩转换为A、B、C、D和E:成绩在90分以上,结果为A,成绩在80-90之间,结果为B,成绩在70-80之间,结果为C,成绩在60-70之间,结果为D,成绩在60分以下,结果为E。*/

public class Chengfabiao

{

public static void main (String[] args)

{

Scanner scanner = new Scanner(System.in);

int score = scanner.nextInt();

if(score90)

{

System.out.println("A");

}

else if(score=80)

{

System.out.println("B");

}

else if(score=70)

{

System.out.println("C");

}

else if(score=60)

{

System.out.println("D");

}

else

{

System.out.println("E");

}

}

}

用java编写一个简单例子,题目如下

package test;

public class Student {

private String name;

private String id;

private String clazz;

private int age;

private String address;

/**

* sayHello方法

*/

public void sayHello() {

System.out.println("学号为" + this.id + "的同学的具体信息如下:");

System.out.println("姓名:" + this.name);

System.out.println("班级:" + this.clazz);

System.out.println("年龄:" + this.age);

System.out.println("家庭住址:" + this.address);

}

/**

* 测试方法

*

* @param args

*/

public static void main(String[] args) {

// 第一问

Student student = new Student();

student.setAddress("百度知道");

student.setAge(1);

student.setClazz("一班");

student.setId("071251000");

student.setName("lsy605604013");

student.sayHello();

// 第二问

Student studentNew = new Student();

studentNew.setAddress("搜搜知道");

studentNew.setAge(2);

studentNew.setClazz("二班");

studentNew.setId("071251001");

studentNew.setName("lady");

if (student.getAge() studentNew.getAge())

studentNew.sayHello();

else if (student.getAge() studentNew.getAge())

student.sayHello();

else

System.out.println("两人一样大");

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getId() {

return id;

}

public void setId(String id) {

this.id = id;

}

public String getClazz() {

return clazz;

}

public void setClazz(String clazz) {

this.clazz = clazz;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

public String getAddress() {

return address;

}

public void setAddress(String address) {

this.address = address;

}

}


名称栏目:Java编程代码示例,java编程例子
网站URL:http://kswjz.com/article/hdossp.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流