呆牛2004-09-10 04:22:16
哥哥,姐姐,帮帮忙吧!今年刚在学校take java,不过我还是不是很开窍!昨天写了个programe,不知道哪里出现了问题,希望个位帮帮忙,小弟先谢了!

1. The following sequence of steps will be used to convert a license plate into a car rental code.

a. A license plate consists of 3 letters followed by a 3 digit integer value.
b. type in the license plate information as 3 characters followed by a single integer value. For Exple, CPR 607
c. Add up the ASCII values of the 3 letters, 67+80+82+229.
d. Add the sum of the letters to the single integer value. For example, 229+607+836.
e. Take this sum (836) and determine the integer remainder after dividing by 26: 836%26=4.
f. Determine the 4th letter in the alphabet after the letter "A":4th letter after "A"=E
g. combine the letter and the sum, the car ide number for license plate CPR 607
=e836

2. yOU MAY ASSUME THAT ALL SAMPLE DATA WILL BE IN THE FORMAT OF 3 ALPHABET CHARACTERS, THEN A SPACE, FOLLLOWED by a 3 digit integer.

这下面是我写的,不好意思:

public class CarRental{
public static void main(String [] args){
//declare & inl.test reading
TextReader TextR= new TextReader();

//prompt for Make and Model
System.out.println ("Type in The Make of Your car");
char Make=TextR.readLine();

System.out.println ("Type in The Model of Your car");
char Model=TextR.readLine();

//prompt for the car info
System.out.println ("Type in The license plate information as 3characters followed by a single value");

char a=TextR.readchar();
char b=TextR.readchar();
char c=TextR.readchar();

int no1=TextR.readInt();

int x1=(int)(a);
int x2=(int)(b);
int x3=(int)(c);
int x4=(int)(no1);

int x5=a+b+c+no1;
int x6=x5%26;

char x7=(char)((int)("A")+x6);

System.out.println ("Make ="+Make);
System.out.println ("Model ="+Model);
System.out.println (x1+x2+x3+x4+"="+x7);
}
}


我也不知道我的思路对不对,就是不工作,我先谢谢大家了!!
要是眉眉俺就说了2004-09-10 05:57:13
这都搞不定??现在孩子的智商真实越来越低啊!!!
呆牛2004-09-10 08:38:52
用你罗嗦呀!我自己搞定了!
不是眉眉也说2004-09-10 15:45:00
char x7=(char)((int)('A')+x6);