帮我做一个Java的一个小程序

Typically,booksareidentifiedbyanInternationalStandardBookNumber(ISBN)whichadherestoas... Typically, books are identified by an International Standard Book Number (ISBN) which adheres to a specific format, e.g. 0-393-30375-A.

Write a program that generates a random ISBN that follows the following rules:

a. The first digit indicates whether the language in which the book is written is English; this is must be a zero or one.

b. The next group of three digits specifies the publisher and must not contain an 8 or a 9

c. The group after that is a number assigned by the publisher to identify the book. The publisher is prompted to enter a value between 10000 and 99999 (it is not randomly generated). No validation needs to be preformed.

d. The ISBN ends with a random uppercase character (A-Z), called a check character.

Then display the ISBN number in the following format:
a-bbb-ccccc-d.

Your programs output should look like this:

ISBN is 0-123-45678-X

Language = 0
Publisher = 123
Book = 45678
Check = X
展开
 我来答
匿名用户
2009-08-11
展开全部
public class Test {
public static void main(String[] args) {
Random random = new Random();
int a = random.nextInt(2);
int b = random.nextInt(8);
int c = random.nextInt(8);
int d = random.nextInt(8);
int e = random.nextInt(90000) + 10000;
char f = (char) (random.nextInt(26) + 'A');

System.out.printf("ISBN is: %d-%d%d%d-%d-%c\n", a, b, c, d, e, f);
System.out.printf("Language = %d\n", a);
System.out.printf("Publisher = %d%d%d\n", b, c, d);
System.out.printf("Book = %d\n", e);
System.out.printf("Check = %c", f);
}

}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式