請教Java(Java 高手請近)

來源: 呆牛 2004-09-09 20:22:16 [] [舊帖] [給我悄悄話] 本文已被閱讀: 次 (2101 bytes)
哥哥,姐姐,幫幫忙吧!今年剛在學校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);
}
}


我也不知道我的思路對不對,就是不工作,我先謝謝大家了!!

所有跟帖: 

這都搞不定??現在孩子的智商真實越來越低啊!!! -要是眉眉俺就說了- 給 要是眉眉俺就說了 發送悄悄話 (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

請您先登陸,再發跟帖!

發現Adblock插件

如要繼續瀏覽
請支持本站 請務必在本站關閉/移除任何Adblock

關閉Adblock後 請點擊

請參考如何關閉Adblock/Adblock plus

安裝Adblock plus用戶請點擊瀏覽器圖標
選擇“Disable on www.wenxuecity.com”

安裝Adblock用戶請點擊圖標
選擇“don't run on pages on this domain”