哥哥,姐姐,幫幫忙吧!今年剛在學校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);
}
}
我也不知道我的思路對不對,就是不工作,我先謝謝大家了!!
請教Java(Java 高手請近)
所有跟帖:
• 這都搞不定??現在孩子的智商真實越來越低啊!!! -要是眉眉俺就說了- ♀ (0 bytes) () 09/09/2004 postreply 21:57:13
• 用你羅嗦呀!我自己搞定了! -呆牛- ♂ (0 bytes) () 09/10/2004 postreply 00:38:52
• char x7=(char)((int)('A')+x6); -不是眉眉也說- ♀ (0 bytes) () 09/10/2004 postreply 07:45:00