1、 编写一个程序Java1,定义书Book类:
  1)、包含成员变量:书名称(name),作者(author)、出版社(publisher)、定价(price), 并设置为private
  2)、编写public的无参数和有参数构造函数
  3)、编写public的显示函数show()
  4)、在main函数中产生Book的对象,用show显示2、编写一个程序Java2,输入一个文本文件的名称,显示出该文件的内容。3、编写一个程序Java3,输入一个字符串,统计出各个字母'A'-'Z'(不分大小写)分别出现的次数,显示输出。
提示输入字符串:
   import java.io.*;
......
   BufferedReader stdin =new BufferedReader(new InputStreamReader(System.in));
   System.out.print("Enter a line:");
   System.out.println(stdin.readLine());

解决方案 »

  1.   

    他真是女的!
    认识的在QQ问过我!
    但是我在高C/C++帮不了你,所以叫他上这里问 呵呵!
      

  2.   

    public class Exercise1
    {
    public static void main(String[] args)
    {
    Book[] b={new Book(),new Book("book1","zhangshan","Sun",99)};
    for(Book a:b)
    a.show();
    }
    }
    class Book
    {
    public Book()
    {
    name="Core Java 2";
    author="Gary cornell";
    publisher="Sun";
    price=88.00;
    }
    public Book(String name,String author,String publisher,double price)
    {
    this.name=name;
    this.author=author;
    this.publisher=publisher;
    this.price=price;
    }
    public void show()
    {
    System.out.println("The book name is "+name+", author is "+author+" ,publisher is "+publisher+" ,price is "+price);
    }
    private String name;
    private String author;
    private String publisher;
    private double price; 
    }
      

  3.   

    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.Scanner;public class Exercise2
    {
    public static void main(String[] args) throws IOException
    {
    Scanner in=new Scanner(System.in);
    String filename;
    if(args.length>0)
    {
    filename=args[0];
    }
    else
    {
    System.out.println("请输入文件绝对路径");
    filename=in.next();

    }
    if(filename==null || filename.equals(""))
    {

    System.out.println("请输入文件绝对路径???");
    }
    else
    {
    new Exercise2().readFile(filename);
    }
    }
    public void readFile(String filename) throws IOException
    {
    FileInputStream fis=new FileInputStream(filename);
    byte[] buf=new byte[10000];
    int len=fis.read(buf);
    System.out.println(new String(buf,0,len));
    }
    }
      

  4.   

    import java.util.*;
    public class Exercise3
    {
    public static void main(String[] args)
    {
    Scanner in=new Scanner(System.in);
    System.out.println("输入个字符串");
    String s=in.next();
    char[] c=s.toCharArray();
    System.out.println(c);
    new Exercise3().printChar(c);

    }
    public void printChar(char[] line)
    {
    char[] ch=new char[line.length];
    int[] counter=new int[line.length];
    int flag=0;
    for(int i=0;i<line.length;i++)
    {
    boolean b=false;
    for(int j=0;j<=i;j++)
    {
    if(ch[j]==line[i])
    {
    counter[j]++;
    b=true;
    continue;
    }
    }
    if(!b)
    {
    ch[flag]=line[i];
    counter[flag]++;
    flag++;
    }
    }
    String s=new String(line);
    System.out.println("你输入的字符串是:"+ s+" 其中:" );
    for(int i=0;i<ch.length;i++)
    {
    if(ch[i]!=0)
    System.out.println(ch[i]+" 出现了 "+counter[i]+" 次");

    }
    }
    }
      

  5.   

    现在不是盛行女权主义,女人天天喊女权,男女平等,但一遇到问题,马上就“小女子”了,把自己摆在了一个等待别人帮助的角色上,这个时候就一点点“大女人”主义都没有了?
    要不说“小女子”可能还好些。
    虽然我也是菜鸟,但还是看不惯这样作业都要别人帮做的,以后出来,工作上的项目也要别人帮着做?不过现在这样的人还真不少?刚在别的论坛也才遇到过一个。http://bbs.blueidea.com/thread-2760765-1-1.html
      

  6.   

    不管怎么样,既然楼主提出帮助来了
    就应该帮他啊,不应该看问题片面
    管她性别什么事啊
    phoenixzong()  热心人....
      

  7.   

    呵知道怎么写的人就帮下吧我是asp.net/C#的以后还是不要写小女子了。。
      

  8.   

    public class Book {
        String name,author,publisher;
        private  double price;
        public Book() {
        }
        public Book(String name,String author,String publisher,double price) {
            this.name=name;
            this.author=author;
            this.publisher=publisher;
            this.price=price;
        }
        String GetName(){
        return name;
        } 
        String GetAuthor(){
       return author;
       } 
       String GetPublisher(){
       return publisher;
       } 
       double GetPrice(){
       return price;
       }
        public void show(){
        System.out.print(GetName()+" "+GetAuthor()+ " "+GetPublisher()+" "+GetPrice());
        }
        
        public static void main(String[] args){
        Book f=new Book("左手年华","小郭","春风出版社",23);
        f.show();
        }
    }
    我写一个,初学,写的没他们好哈.......
      

  9.   

    LZ我也是刚学的,其他问题回答不了,只好在这帮人做作业换点分,就是想我问问题的时候能给点分加人,呵呵,有空把分给我吧,我也不富裕呀。
    忘了说了,第二题关于io我还没学到,看API做的,可能经不住测试,第三题把char[] ch=s.toCharArray() 改成char[] c=s.toLowerCase().toCharArray();就不区分大小写了。
      

  10.   

    终于知道为什么说csdn现在人是越来越多,高手却是懒的呆在这里了.类型于JDK的安装这种问题,麻烦就不要在问了,看看Docs就可以了的.真不知道怎么想的.
      

  11.   

    没事做帮你写一下 
    第一题
    Public class a {
    Public class book
    {
    Private String name;
    Private String author;
    Private String publisher;
    Private float price;
    public Book()
    {
    name="think in java";
    author=" ";
    publisher="Sun";
    price=120;
    }
    public Book(String name,String author,String publisher,float price)
    {
    this.name=name;
    this.author=author;
    this.publisher=publisher;
    this.price=price;
    }
    Public void show()
    {
    System.out.println(“book name is ”+name);
    System.out.println(“book author is ”+ author);
    System.out.println(“book price is ”+ price);}
    }
    public static void main(String[] args)
    {
    Book book1=new book();
    Book1.show();
    }
    }
      

  12.   

    这个问题貌似最基本的学Java的书上都有翻翻不就有了
      

  13.   

    blooney(野比) 不好意思说那个字,我说
    解决这种问题的人
    一个字:贱
      

  14.   

    是人妖吧.要不然就是gay.不然为什么非得说是小女子呢.很贱的味道;
    package homework;public class Book {
    String n; String a; String p; double d; private void book(String name, String auther, String publisher, double price) {
    n = name;
    a = auther;
    p = publisher;
    d = price; } void show() {
    System.out.println("书名是:" + n);
    System.out.println("作者:" + a);
    System.out.println("出版社:"+p);
    System.out.println("价钱:" + d); }
    public static void main(String[] args) {
    Book test=new Book();
    test.book("人妖", "我", "北京", 25.3);
    test.show();
    }}
      

  15.   

    第一题还还用问啊,只要学过java的都做得出来,按照字面意思翻译就行了,根本就不需要懂点脑筋