永发信息网

求程序员帮忙写个Java代码,因为今天我有事没时间做,明天要交作业,谢谢了

答案:6  悬赏:80  手机版
解决时间 2021-02-04 14:35
求程序员帮忙写个Java代码,因为今天我有事没时间做,明天要交作业,谢谢了
最佳答案
代码如下,随便附一句,一定要看写的源码,我已经尽量马马虎虎的写了,你更容易看懂。
public class Test {

// 第八题
public static final int NUM = 100;
public static final double GOOD = 99.99;
public static final String CLASSNAME = "Test.Class";
public static final long MAX = 9999999;

public static void main(String[] args) {

// 第一题
byte byte1 = 1;
short short1 = 1;
int int1 = 1;
long long1 = 1;
float float1 = 1;
double double1 = 1.0;

System.out.println("byte1 - " + byte1);
System.out.println("short1 - " + short1);
System.out.println("int1 - " + int1);
System.out.println("long1 - " + long1);
System.out.println("float1 - " + float1);
System.out.println("double1 - " + double1);

// 第二题
String name;
char sex;
int age;
boolean isMember;

// 第三题
int score1;
double score2 = 98.5;

// 第四题
double f1 = 10.1, f2 = 34.2;
System.out.println("f1,f2的和:" + (f1 + f2));
System.out.println("f1,f2的差:" + (f1 - f2));
System.out.println("f1,f2的积:" + (f1 * f2));
System.out.println("f1,f2的商:" + (f1 / f2));

// 第五题
int f3 = 5;
double f4 = 45.6;
System.out.println("f3,f4的和:" + (f3 + f4));
System.out.println("f3,f4的差:" + (f3 - f4));
System.out.println("f3,f4的积:" + (f3 * f4));
System.out.println("f3,f4的商:" + (f3 / f4));

// 第六题
int A = 65;
char a = (char) A;
System.out.println("整型互转char:" + a);

// 第七题
double timor = 123.456789;
int x = Integer
.parseInt(new java.text.DecimalFormat("0").format(timor));// 四舍五入
System.out.println("double -> int :" + x);

// 第八题(定义在最开始)
System.out.println("常量NUM的值: " + NUM);
System.out.println("常量GOOD的值: " + GOOD);
System.out.println("常量CLASSNAME的值: " + CLASSNAME);
System.out.println("常量MAX的值: " + MAX);

// 第九题(自定义商品类)
class Goods {

private String name;
private double price;
private int count;
private double total;

public Goods(String name, double price, int count) {
this.name = name;
this.price = price;
this.count = count;
}

public void print() {
total = price * count;
System.out.println("商品名   价格      数量  总价");
System.out.println(name + "  " + price + "  " + count + "  "
+ total);
}

}
Goods goods = new Goods("苹果", 2, 10);
goods.print();

// 第十题
double pi = 3.14, r, d;
r = 4;
d = 2 * r;

System.out.println("圆的周长: " + (pi * d));
System.out.println("圆的面积: " + (pi * r * r));

// 第十一题
String qqname = "1234567890";
String qqpassword = "asd!#@#$%66";
Date birth = new Date(2014, 5, 1);
boolean isVIP = false;
char sex1 = '男';
StringBuilder personInfo = new StringBuilder();
personInfo.append("我是一个快乐的骚年");
personInfo
.append("然后a!#$%^&*asdasdasdasdsa9d87a9s8d79asdjidauisdhausdihiasd");

// 第十二题
class Swaper {
public void change(int num1, int num2) {
int temp = num1;
num1 = num2;
num2 = temp;
System.out.printf("a=%d,b=%d
", num1, num2);
}

}

int a1 = 2;
int b1 = 5;
Swaper swaper = new Swaper();
swaper.change(a1, b1);
}
}
全部回答
可以给你写这个的 写吗
都挺简单的 还是自己思考吧。。
对我来说太难了,你自己做吧
这写东西5分钟都用不了,自己做,好好学习不要偷懒!!!
不帮你写是为你好,再忙这点作业还是有时间的吧,不要偷懒
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
有离婚了再复婚的吗?过得好吗?
手机登录中国移动掌上营业厅,显示无法获得操
张马中心校地址有知道的么?有点事想过去
根据已学习的知识,完成下面的概念图:①②
家宴羊肉锅子饼我想知道这个在什么地方
魔兽世界里情人节那个用真银箭头制造一个永久
韩咀中心校地址好找么,我有些事要过去
现货原油投资周末开不开盘
梦园路地址在什么地方,想过去办事
找出每组划线部分的读音与其他三个不同的选项
中咀中心校地址在什么地方,我要处理点事
如何约天蝎女
读书乐在其中的作文
贡菜怎么吃啊?
有期徒刑3年,缓刑3年如何执行?是不是不需要
推荐资讯
荒岛求生探索咋样玩
和小猫怎么接触就会得猫藓
2016楚雄牟定三月会是哪天
大专主要学什么
利欣耀副食超市这个地址在什么地方,我要处理
广州花都有什么好的工作介绍下!!
海口市海甸岛周边农行开户行是哪
计算题:某容器真空表读数p1为96.08kPa,当地
厦门航空(涵江售票处)地址好找么,我有些事要
a un health expert warns that a new flu pa
燕子化妆美甲店地址在哪,我要去那里办事
南海区西樵高级中学地址有知道的么?有点事想
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?