编写一个Java应用程序,在其中编写一个类
答案:3 悬赏:0
解决时间 2021-11-26 19:59
- 提问者网友:迷茫庸人
- 2021-11-25 21:54
编写一个Java应用程序,在其中编写一个类,该类封装了一元二次方程共有的属性和功能,即该类有刻画方程系数的3个成员变量以及计算实根的方法,并给出计算实根的过程。
最佳答案
- 二级知识专家网友:我的任性你不懂
- 2021-11-25 22:49
import java.util.*;
public class yugi{
public static void main(string[] args){
scanner scan = new scanner(system.in);
system.out.println("输入班级人数:");
int num = scan.nextint();
double sum = 0;
double max = double.min_value;
double min = double.max_value;
for(int i = 0; i < num; i++){
system.out.print("输入第" + (i + 1) + "个学生的成绩: ");
double score = scan.nextdouble();
sum += score;
max = score > max ? score : max;
min = score < min ? score : min;
}
scan.close();
double avg = sum / num;
system.out.printf("班级人数: %d,最高分: %.2f,最低分: %.2f,平均分: %.2f", num, max, min, avg);
}
}
public class yugi{
public static void main(string[] args){
scanner scan = new scanner(system.in);
system.out.println("输入班级人数:");
int num = scan.nextint();
double sum = 0;
double max = double.min_value;
double min = double.max_value;
for(int i = 0; i < num; i++){
system.out.print("输入第" + (i + 1) + "个学生的成绩: ");
double score = scan.nextdouble();
sum += score;
max = score > max ? score : max;
min = score < min ? score : min;
}
scan.close();
double avg = sum / num;
system.out.printf("班级人数: %d,最高分: %.2f,最低分: %.2f,平均分: %.2f", num, max, min, avg);
}
}
全部回答
- 1楼网友:山鬼偶尔也合群
- 2021-11-26 01:31
package practice1;
public class C {
private double a;
private double b;
private double c;
private double[] d;
public String[] i;
public void setValue(double a, double b, double c) {
this.a = a;
this.b = b;
this.c = c;
this.d = new double[2];
this.i = new String[2];
}
public boolean canGetValue() {
double temp;
temp = b * b - 4 * a * c;
if (temp < 0) {
this.i[0] = (-b) / (a * 2) + "+" + Math.sqrt(-temp) / (2 * a) + "i";
this.i[1] = (-b) / (a * 2) + "-" + Math.sqrt(-temp) / (2 * a) + "i";
return false;
} else {
this.d[0] = (-b + Math.sqrt(temp)) / (2 * a);
this.d[1] = (-b - Math.sqrt(temp)) / (2 * a);
return true;
}
}
public double getA() {
return a;
}
public double getB() {
return b;
}
public double getC() {
return c;
}
public double getD(int i) {
return d[i];
}
public static void main(String[] args) {
// TODO Auto-generated method stub
C pratice1 = new C();
pratice1.setValue(1, 3, 4);
if (pratice1.canGetValue()) {
System.out.println(pratice1.getA());
System.out.println(pratice1.getB());
System.out.println(pratice1.getC());
System.out.println(pratice1.getD(0));
System.out.println(pratice1.getD(1));
} else {
System.out.println(pratice1.i[0]);
System.out.println(pratice1.i[1]);
}
}
}
- 2楼网友:山鬼偶尔也合群
- 2021-11-25 23:59
JAVA也应用程序 你进水了 JAVA写应用程序拉吉的一比 也web 还差不多
麻烦 还要设计界面 直接易语言 1分钟搞定
手机应用的话 除外
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯