zoukankan      html  css  js  c++  java
  • Homework1

     Program1

    import java.net.*;
    import java.io.*;
    /**  A class that provides a main function to read five lines of a commercial
     *   Web page and print them in reverse order, given the name of a company.
     */
    
    class OpenCommercial {
    
      /** Prompts the user for the name X of a company (a single string), opens
       *  the Web site corresponding to www.X.com, and prints the first five lines
       *  of the Web page in reverse order.
       *  @param arg is not used.
       *  @exception Exception thrown if there are any problems parsing the 
       *             user's input or opening the connection.
       */
      public static void main(String[] arg) throws Exception {
    
        BufferedReader keyboard;
        String inputLine;
    
        keyboard = new BufferedReader(new InputStreamReader(System.in));
    
        System.out.print("Please enter the name of a company (without spaces): ");
        System.out.flush();        /* Make sure the line is printed immediately. */
        inputLine = keyboard.readLine();
    
        /* Replace this comment with your solution.  */
        
        URL u = new URL("http://www."+inputLine+".com");
        InputStream ins=u.openStream();
        InputStreamReader isr= new InputStreamReader(ins);
        BufferedReader bd = new BufferedReader(isr);
        
        String[] outprint=new String[5];
        for (int j=4;j>=0;j--) {
        	outprint[j]=bd.readLine()+"
    ";//have nothing to do
        }
    
        for(int i=0;i<5;i++) {
        	System.out.print(outprint[i]);//have no idea why I cannot use printIn
        }
      } 
    }   
    

    println...小写L,不是大写i....

    Program2 Nuke

    import java.io.*;
    
    class OpenCommercial {
      public static void main(String[] arg) throws Exception {
    
        BufferedReader keyboard;
        String inputString;
        keyboard = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Input A String: ");
        System.out.flush();     
        inputString = keyboard.readLine();
    
        String former=new String(inputString.substring(0,1));
        String latter=new String(inputString.substring(2,inputString.length()));
        
        System.out.print(former+latter);
      }
    }
    
  • 相关阅读:
    Vault插件示例--Vault Explorer与Thin Client的集成。
    什么是REST?
    Android Tips: 打电话和发短信
    使用Autodesk Vault插件向导轻松创建Vault插件
    智者当借力而行, 借助Autodesk应用程序商店实现名利双收
    MapGuide Maestro 5.1发布了
    ArcGIS ElementLayer上放置Windows控件
    ArcGIS图层和要素的过滤显示
    ArcGIS中的三种查询
    ArcGIS图层介绍
  • 原文地址:https://www.cnblogs.com/Miaostarer/p/7163445.html
Copyright © 2011-2022 走看看