Java编程高手速度来啊~~帮忙写一程序,搞定了给100分!

2024-11-29 18:10:38
推荐回答(3个)
回答1:

很简单啊?你要写那个?
帮你写个最简单的
第一题:
import java.util.Scanner;

/**
* Created by IntelliJ IDEA.
* User: guangzhi
* Date: 11-10-19
* Time: 下午2:13
* To change this template use File | Settings | File Templates.
*/
public class JiSuan {
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
int score = 0;
for(int i = 0; i < 10 ; i++){
score = score + (new JiSuan().compute(i,cin))*10;
}
System.out.println("Score :"+score);
}
public int compute(int count,Scanner cin){
int numA = (int) (Math.random()*10)+1;
int numB = (int) (Math.random()*10)+1;
int operate = (int)(Math.random()*4);

if(operate == 0){
System.out.println("Question " + count + ":"+ numA + "+" + numB + "=?");
int myAnswer = cin.nextInt();
int result = numA + numB;
if(myAnswer == result){
return 1;
}else{
return 0;
}
}else if(operate == 1){
System.out.println("Question " + count + ":"+ numA + "-" + numB + "=?");
int myAnswer = cin.nextInt();
int result = numA - numB;
if(myAnswer == result){
return 1;
}else{
return 0;
}
}else if(operate == 2){
System.out.println("Question " + count + ":"+ numA + "*" + numB + "=?");
int myAnswer = cin.nextInt();
int result = numA * numB;
if(myAnswer == result){
return 1;
}else{
return 0;
}
}else{
System.out.println("Question " + count + ":"+ numA + "/" + numB + "=?(no radix point)");
int myAnswer = cin.nextInt();
int result = numA / numB;
if(myAnswer == result){
return 1;
}else{
return 0;
}
}
}
}

第二个:
import java.util.Scanner;

/**
* Created by IntelliJ IDEA.
* User: guangzhi
* Date: 11-10-19
* Time: 下午1:47
* To change this template use File | Settings | File Templates.
*/
public class CaiShuZi {
public static void main(String[] args){
int r = (int)(Math.random()*100);
int guessNumber;
int count = 1;

Scanner cin = new Scanner(System.in);
System.out.print("System generate a random number.Please enter your guess number:");
guessNumber = cin.nextInt();

while(true){
if(guessNumber < r){
System.out.println("Your number is less than the random number.Please guess again: ");
count ++;
guessNumber = cin.nextInt();
}else if(guessNumber > r){
System.out.println("Your number is greater than the random number.Please guess again: ");
count ++;
guessNumber = cin.nextInt();
}else{
switch (count){
case 1:
System.out.print("Perfect "+count);
break;
case 2:
System.out.print("Congratulation "+count);
break;
case 3:
System.out.print("Nice "+count);
break;
case 4:
System.out.print("Good "+count);
break;
case 5:
System.out.print("So So "+count);
break;
default:
System.out.print("You can do it better.");
}
break;
}
}

}
}

回答2:

有几题还是挺简单的,就是题目太多了,难得敲出来

回答3:

现作的, 有bug的话站内短信我

要处理的文件必须先改成英文名( 只含ASCII的名字 )
fstream不能直接打开中文名文件, 而setlcale和locale::global也会造成不能显示或报错( 网上的方法和我自己尝试都不行 ), 我也不想用c或api来代替, 只能凑合一下了; 或者你自己改下代码, 用其他文件打开方式

#include