「java超分」Java超类
今天给各位分享java超分的知识,其中也会对Java超类进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
- 1、超高分java题,最好会英语能看懂哦,请高手再帮我写成程序
- 2、如何利用JAVA显示所有超过平均分的分数和下标;
- 3、JAVA作业一份 超高分+高附加分
- 4、使用java从键盘输入比赛的十句成绩如果大于80分的超过90%则恭喜!通过一如果超过60
- 5、如何令java线程池中线程超过5分钟时该线程自杀
超高分java题,最好会英语能看懂哦,请高手再帮我写成程序
So easy!
1、Find out the max and the min through a for loop ,then return max-min;
public int getRange(int [] Array){
int max=Array[0];
int min=Array[0];
for(int i=1;iArray.length;i++){
if (Array[i]max)
{
max=Array[i];
}
else if (Array[i]min)
{
min=Array[i];
}
}
return max-min;
}
2、 public void printArray(int n){
for(int i=0;in;i++){
System.out.println((a+2*i).toString()+" "+( b+5i).toString()+" ");
}
}
哈哈,见笑了。看见这么多英语,一时兴起,就说起了我的chinglish;
上面的代码是在脑部运行了一下,没有什么大的问题;
其实这些都不难,如果这个是楼主的专业课的话,一开始一定要学好呀;不然以后想学好时,发现入不了门了,那就后悔也晚啦。
如何利用JAVA显示所有超过平均分的分数和下标;
假设strArr为你想操作的目标数组; strArr[x] = y; 其中x:第n个元素(数组下标从0开始,如果想给第二个元素赋值,那么就要取下标为2-1的元素即strArr[1]);y:赋值后的结果
JAVA作业一份 超高分+高附加分
你的题目提到的参考文件和测试资料都没有,不太清楚具体要弄成什么样。主要的功能给你实现了:
import java.util.Scanner;
public class QuadraticPolynomialTUI {
public double[] findRoots(double a, double b, double c) {
double rootSquare = b*b - 4*a*c;
if(rootSquare0) return null;
if(rootSquare==0)
return new double[] {-b/2/a};
else
return new double[] {(-b+Math.sqrt(rootSquare))/2/a, (-b-Math.sqrt(rootSquare))/2/a};
}
public String formatPolynomial(double a, double b, double c) {
return (a0?"- "+(-a):""+a) + "X^2" + (b0?" - "+(-b):" + "+b) + "X" + (c0?" - "+(-c):" + "+c);
}
}
class PolynomialStart {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
QuadraticPolynomialTUI qptui = new QuadraticPolynomialTUI();
do {
System.out.print("Input a: ");
double a = s.nextDouble();
System.out.print("Input b: ");
double b = s.nextDouble();
System.out.print("Input c: ");
double c = s.nextDouble();
System.out.println(qptui.formatPolynomial(a, b, c));
double[] roots = qptui.findRoots(a, b, c);
if(roots==null) System.out.println("This polynomial has no real roots");
else
for(double root:roots)
System.out.print(root+" ");
System.out.println();
System.out.print("Input another one?(Y/N)");
} while(s.next().equalsIgnoreCase("y"));
}
}
使用java从键盘输入比赛的十句成绩如果大于80分的超过90%则恭喜!通过一如果超过60
package com.arthur.test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Test {
public static void main(String[] args) throws Exception{
Test t = new Test();
t.process();
}
public void process() throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
System.out.print("请输入10个比赛成绩,用逗号分隔: ");
String input = br.readLine();
if(input==null || input.trim().length()==0){
System.out.println("输入错误!");
System.exit(0);
}
String[] values = input.trim().split(",");
if(values.length != 10){
System.out.println("输入比赛成绩个数错误!");
System.exit(0);
}
int[] scores = new int[10];
for(int i=0; i10; i++){
try{
scores[i] = Integer.parseInt(values[i].trim());
}catch(Exception e){
System.out.println("第 " + (i+1) + " 个比赛成绩不是数字:" + values[i]);
System.exit(0);
}
}
dispSummary(scores);
}
//如果大于80分的超过90%则恭喜!通过一如果超过60......
private void dispSummary(int[] nums){
int gt80 = 0;
int gt60 = 0;
// .... 其他条件
for(int i=0; inums.length; i++){
if(nums[i] 80)
gt80++;
if(nums[i] 60)
gt60++;
//... 其他条件
}
if(gt80*100/nums.length = 90)
System.out.println("恭喜! 通过!");
else if(gt60*100/nums.length = 90)
System.out.println("不错! 合格!");
else
System.out.println("不怎么地! 努力吧!");
}
}
如何令java线程池中线程超过5分钟时该线程自杀
public void run() {
while (true) {
if (Thread.currentThread().isInterrupted()) {
return;
}
// do something
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
如果线程任务是这种形式,使用thread.Interrupt 的方法来打断thread, 从而结束该thread的生命周期。
关于java超分和Java超类的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
发布于:2022-11-26,除非注明,否则均为
原创文章,转载请注明出处。