java 问题,下面代码是我一个朋友写的,你们认为他技术水平怎么样?他刚刚毕业,大专的
publicclassWork{publicstaticvoidmain(String[]args){double[][]data=newdouble[][]{{9,10...
public class Work {
public static void main(String[] args) {
double[][] data = new double[][] { { 9, 10, 9, 9, 6 }, { 8, 9, 10, 7, 5 },
{ 10, 7, 8, 9, 9 }, { 7, 5, 7, 8, 4 }, { 6, 5, 5, 6, 6 },
{ 6, 8, 8, 9, 7 }, { 7, 7, 8, 7, 6 }, { 9, 10, 9, 8, 9 },
{ 4, 7, 8, 6, 8 }, { 5, 8, 7, 8, 6 }, { 6, 9, 5, 9, 7 },
{ 7, 6, 6, 8, 7 }, { 4, 5, 3, 5, 6 }, { 7, 6, 4, 5, 6 },
{ 4, 5, 4, 4, 3 }, { 8, 9, 9, 8, 7 }, { 6, 7, 5, 4, 6 },
{ 7, 8, 7, 7, 5 }, { 9, 8, 9, 7, 4 } };
System.out.println("c1的公式执行如下:");
for (int i = 0; i < data.length; i++) {
c1(data[i]);
}
System.out.println("c2的公式执行如下:");
for (int i = 0; i < data.length; i++) {
c2(data[i]);
}
System.out.println("c3的公式执行如下:");
for (int i = 0; i < data.length; i++) {
c3(data[i]);
}
System.out.println("c4的公式执行如下:");
for (int i = 0; i < data.length; i++) {
c4(data[i]);
}
System.out.println("c5的公式执行如下:");
for (int i = 0; i < data.length; i++) {
c5(data[i]);
}
}
private static void c1(double[] c1) {
double sum=0;
DecimalFormat df=new DecimalFormat("####0.00");
for (int i = 0; i < c1.length; i++) {
if (c1[i] >= 0 && c1[i] < 1) {
// System.out.print("1,");
sum=1;
}
if (c1[i] >= 1 && c1[i] < 2) {
// System.out.printf("%.2f",((2 - c1[i])) );
sum+=Double.parseDouble(df.format((2 - c1[i])));
// System.out.print(",");
}
if (!(c1[i] >= 0 && c1[i] < 2)) {
// System.out.print("0,");
sum=0;
}
System.out.println("sum="+sum);
}
System.out.println();
}
private static void c2(double[] c2) {
for (int i = 0; i < c2.length; i++) {
if (c2[i] >= 0 && c2[i] < 2) {
System.out.printf("%.2f",(c2[i] / 2));
System.out.print(",");
}
if (c2[i] >= 2 && c2[i] < 4) {
System.out.printf("%.2f",(4 - c2[i]) / 2 );
System.out.print(",");
}
if (!(c2[i] >= 2 && c2[i] < 4)) {
System.out.print("0,");
}
}
System.out.println();
}
private static void c3(double[] c3) {
for (int i = 0; i < c3.length; i++) {
if (c3[i] >= 0 && c3[i] < 3) {
System.out.printf("%.2f",(c3[i] / 3) );
System.out.print(",");
}
if (c3[i] >= 3 && c3[i] < 6) {
System.out.printf("%.2f",((6 - c3[i]) / 3) );
System.out.print(",");
} else if (!(c3[i] >= 0 && c3[i] < 6)) {
System.out.print("0,");
}
}
System.out
..................................... 展开
public static void main(String[] args) {
double[][] data = new double[][] { { 9, 10, 9, 9, 6 }, { 8, 9, 10, 7, 5 },
{ 10, 7, 8, 9, 9 }, { 7, 5, 7, 8, 4 }, { 6, 5, 5, 6, 6 },
{ 6, 8, 8, 9, 7 }, { 7, 7, 8, 7, 6 }, { 9, 10, 9, 8, 9 },
{ 4, 7, 8, 6, 8 }, { 5, 8, 7, 8, 6 }, { 6, 9, 5, 9, 7 },
{ 7, 6, 6, 8, 7 }, { 4, 5, 3, 5, 6 }, { 7, 6, 4, 5, 6 },
{ 4, 5, 4, 4, 3 }, { 8, 9, 9, 8, 7 }, { 6, 7, 5, 4, 6 },
{ 7, 8, 7, 7, 5 }, { 9, 8, 9, 7, 4 } };
System.out.println("c1的公式执行如下:");
for (int i = 0; i < data.length; i++) {
c1(data[i]);
}
System.out.println("c2的公式执行如下:");
for (int i = 0; i < data.length; i++) {
c2(data[i]);
}
System.out.println("c3的公式执行如下:");
for (int i = 0; i < data.length; i++) {
c3(data[i]);
}
System.out.println("c4的公式执行如下:");
for (int i = 0; i < data.length; i++) {
c4(data[i]);
}
System.out.println("c5的公式执行如下:");
for (int i = 0; i < data.length; i++) {
c5(data[i]);
}
}
private static void c1(double[] c1) {
double sum=0;
DecimalFormat df=new DecimalFormat("####0.00");
for (int i = 0; i < c1.length; i++) {
if (c1[i] >= 0 && c1[i] < 1) {
// System.out.print("1,");
sum=1;
}
if (c1[i] >= 1 && c1[i] < 2) {
// System.out.printf("%.2f",((2 - c1[i])) );
sum+=Double.parseDouble(df.format((2 - c1[i])));
// System.out.print(",");
}
if (!(c1[i] >= 0 && c1[i] < 2)) {
// System.out.print("0,");
sum=0;
}
System.out.println("sum="+sum);
}
System.out.println();
}
private static void c2(double[] c2) {
for (int i = 0; i < c2.length; i++) {
if (c2[i] >= 0 && c2[i] < 2) {
System.out.printf("%.2f",(c2[i] / 2));
System.out.print(",");
}
if (c2[i] >= 2 && c2[i] < 4) {
System.out.printf("%.2f",(4 - c2[i]) / 2 );
System.out.print(",");
}
if (!(c2[i] >= 2 && c2[i] < 4)) {
System.out.print("0,");
}
}
System.out.println();
}
private static void c3(double[] c3) {
for (int i = 0; i < c3.length; i++) {
if (c3[i] >= 0 && c3[i] < 3) {
System.out.printf("%.2f",(c3[i] / 3) );
System.out.print(",");
}
if (c3[i] >= 3 && c3[i] < 6) {
System.out.printf("%.2f",((6 - c3[i]) / 3) );
System.out.print(",");
} else if (!(c3[i] >= 0 && c3[i] < 6)) {
System.out.print("0,");
}
}
System.out
..................................... 展开
展开全部
说实话!刚毕业的能写成这样只能说没有搞编程的执导过!所以代码乱只能自己看别人完全没心情看下去!代码格式和注释这些都得认真对待!还有方法命名也有问题!要让人一眼能看懂方法到底是干什么的。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
一段程序每个程序员都有不一样的思路,而你的代码不仅仅是要得出结果,更要让其他的程序员能看懂,格式不知道你是复制过来的时候没有注意还是怎么的,如果是这样的格式,基本上别人看都不会看,在一个方法名和类名要有含义,C2,C3谁能看懂这是什么?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-01-04
展开全部
函数和变量的命名很重要,只能是练手用的,去公司了就要用人家的一套命名规则。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这段代码作用何在?在控制台输出么?任何语言都可以做到,同上面说的一样,我完全没有看下去的心情
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询