public class A(){
String 车牌;
Int 车速;
Double 载重量;
public A(){
this车牌=xx1234;
}
public A(String 车牌,Int 车速,Double 载重量){
this车牌=车牌;
this车速=车速;
this载重量=载重量;
}
加速(){}
减速(){}
修改车牌号(){}
查询载重量(){}
}
return "name = " + name + " stuNum = " + stuNum + " chineseScore = " + chineseScore + " mathScore = " + mathScore + " englishScore = " + englishScore;}//设置姓名public void setName(String name){thisname = name;}//设置学号public void setStuNum(String stuNum){thisstuNum = stuNum;}//设置语文成绩public void setChineseScore(double chineseScore){thischineseScore = chineseScore;}//设置数学成绩public void setMathScore(double mathScore){thismathScore = mathScore;}//设置英语成绩public void setEnglishScore(double englishScore){thisenglishScore = englishScore;}//求总成绩public double getTotalScore(){return chineseScore + mathScore + englishScore;}//求平均成绩
import javamathBigDecimal;
public class Demo {
public static Double[] types = { 001, 002, 005, 01, 02, 05, 10, 20, 50, 100, 200, 500, 1000 };// 人民币币种
public static void main(String[] args) {
Double toMoney = 1000;// 用于支付的100元
Double tpendMoney = 8199;// 实际花费8199元
Double over = DoubleFormat(toMoney - tpendMoney);
Systemoutprintln("找零" + over);
String calc = calc(over);
Systemoutprintln(calc);
}
public static String calc(Double over) {
String resultString = "";
for (int i = 0; i < typeslength; i++) {
if (types[i] >= over) {
if (types[i]equals(over)) {
return types[i]toString();
} else {
resultString += types[i - 1];
resultString += "\t" + calc(DoubleFormat(over - types[i - 1]));
break;
}
}
}
return resultString;
}
public static Double DoubleFormat(Double d) {
BigDecimal bd = new BigDecimal(d);
return bdsetScale(2, BigDecimalROUND_HALF_UP)doubleValue();
}
}
结果:
找零1801
面值:100 , 50 , 20 , 10, 001
Java是一门计算机编程语言,面向对象的编程语言。Java可以开发后端,有spring,springmvc,springboot,springcould等等都是使用Java开发。Java也有前端框架,有Jquery,JavaScript,JSP,Servlet,统称JavaWEB开发。使用Java编写一个程序很简单,按照相关的模板,加上业务代码就可以实现一套系统。
第一题:
import javautilScanner;
public class CountDate {
public static void main(String[] args) {
Scanner s = new Scanner(Systemin);
Systemoutprintln("解放军战士连续作战的小时数:");
int hours = snextInt();
Systemoutprint("解放军战士连续作战");
if(hours <= 0)
Systemoutprintln("解放军战士没奋战啊。。。。。");
if(hours / 24 > 0)
Systemoutprint((hours / 24) + "天");
if(hours % 24 > 0)
Systemoutprint((hours % 24) + "小时");
}
}
第二题
import javautilScanner;
public class GetNumResult {
public static void main(String[] args) {
Scanner s = new Scanner(Systemin);
Systemoutprintln("请输入一个整数:");
int num = snextInt();
for(int i = 1; i <= 10; i ++){
Systemoutprintln(num + " " + i + " = " + (i num));
}
}
}
以上就是关于按要求编写JAVA应用程序。急...帮帮忙吧 非常感谢哦全部的内容,包括:按要求编写JAVA应用程序。急...帮帮忙吧 非常感谢哦、在Java中编写程序,定义一个学生类,属性包括姓名,学号,语文成绩,数学成绩,英语成绩,方法包括输出数、求帮忙 java 编写程序,急急急!!!计算机考试等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)