感谢大神们了
解决方案 »
- 面试题求解
- 无法compile,请问谁能帮我解决一下
- (50分)关于timer类的使用,如何在以下API代码中加入定期执行功能?
- 我一个java问题!
- 如何使用ClassLoader.getSystemResourceAsStream获得资源?
- 求求你们看快来看看我这两个特别简单的问题吧。我实在不知道了。
- 有关使用jni调用c\c++的问题
- 在serversock中,接受用字节流接受一个汉字,字节流动长度为3,为何不是2?如何获取正确的长度?
- 应届的学生想从事JAVA工作他该怎么办?
- csdn是不是嫌人气太旺了,经常进不来!
- 急需解决一个问题,有木有大神,谢谢了
- 求助!javafx中,怎么让一张图片平滑的移动啊
publicdlassT{
@paramargs
E1.7
publicstaticvoidmain(string[] args){Scanner s=new Scanner(System.in);
System.out. print1n("t图书列表);
System.out. println("图书编号图书名称\t图书单价库存数量");
Sys tem.out. println(******)
Bookb1-newBook(1,"java",30.6,30);
Bookb2=newBook(2,"数据结构”,44.6,45);
Bookb3-new Book(3,"数据库“,47.6,21);
b1.show();b2.show();b3. show();
for(int i=1;i<=3;i++){
System.out.println《请输入图书编号选择图书:");
int bookld-s.nextInt();
System.out.printin(”请输入购买图书数量:");
int num=s.nextInt();
if(i==0lli==1){
System.out.println(请继续够购买图书");
}
}
System.out.pnintln("图书订单");
System.out.pnintln("图书订单号000o1");
System.out.println《“图书名称,购买数量,图书单价");
fon(int i=1:i<=3;i++){
for(int j=1;j<=3;j++){
}
}
public static void main(String[] args){
Scanner s = new Scanner(System.in);
System.out.println("图书列表");
System.out.println("图书编号\t图书名称\t图书单价\t库存数量");
System.out.println("**************************");
Book b1=new Book(1,"java",30.6,30);
Book b2=new Book(2,"数据结构",44.6,45);
Book b3=new Book(3,"数据库",47.6,21);
b1.show();
b2.show();
b3.show();
for(int i=1;i<=3;i++){
System.out.println("请输入图书编号选择图书:");
int bookId = s.nextInt();
System.out.println("请输入购买图书数量:");
int num = s.nextInt();
if(i==0||i==1){
System.out.println("请继续够购买图书");
}
}
System.out.println("图书订单");
System.out.println("图书订单号000o1");
System.out.println("图书名称\t购买数量\t图书单价");
for(int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
}
}
}
}Book类public class Book {
public int num = 0;
public String name = "";
public double price = 0.0;
public int count = 0;
public Book(){}
public Book(int num,String name,double price,int count){
this.num = num;
this.name = name;
this.price = price;
this.count = count;
}
public void show(){
String str = num + "\t" + name + "\t" + price + "\t" + count;
System.out.println(str);
}
}完成后的代码,因为你没有其它详细的需求,也不好写太多,比如一些库存之类的public class T {
public static void main(String[] args){
Scanner s = new Scanner(System.in);
System.out.println("图书列表");
System.out.println("图书编号\t图书名称\t图书单价\t库存数量");
System.out.println("**************************");
Book b1=new Book(1,"java",30.6,30);
Book b2=new Book(2,"数据结构",44.6,45);
Book b3=new Book(3,"数据库",47.6,21);
b1.show();
b2.show();
b3.show();
int[] num =new int[3];
int[] count = new int[3];
for(int i=0;i<3;i++){
System.out.println("请输入图书编号选择图书:");
num[i] = s.nextInt();
System.out.println("请输入购买图书数量:");
count[i] = s.nextInt();
if(i==0||i==1){
System.out.println("请继续够购买图书");
}
}
System.out.println("图书订单");
System.out.println("图书订单号00001");
System.out.println("图书名称\t购买数量\t图书单价");
for(int i=0;i<3;i++){
if(num[i]==1){
System.out.println(b1.name +"\t" + count[i] + "\t" +b1.price);
}else if(num[i]==2){
System.out.println(b2.name +"\t" + count[i] + "\t" +b2.price);
}else if(num[i]==3){
System.out.println(b3.name +"\t" + count[i] + "\t" +b3.price);
}
}
}
}