东软能力测评

目录:

1.html表单

2.用户登录验证jsp

3.图书类

4.水仙花

5.编写程序,显示从200到300之间能被3或4整除,但不能被两者同时整除,每行显示10个.

 6.输出1到1000中被7整除或者以7节为的书,每行显示5个

 7.矩阵相乘

 8.已知1900年1月1日是星期1,计算某一年的1月1日是星期几

9.矩形面积

 

1.html表单

<form class="f1" action="from" method="get">

            <table border="1">
                <tbody>
                    <tr>
                        <th align="center">表头</th>
                    </tr>
                    <tr>
                        <td class=“left” width=40% align="right"><label for="t1">姓
                                名:</td>
                        <td class="right"><input type="password" name="Password" /></td>
                    </tr>
                    <tr>
                        <td class=“left” width=40% align="right">密 码:</td>
                        <td class="right"><input type="password" name="Password" /></td>
                    </tr>
                    <tr>
                        <td class=“left” width=40% align="right">确认密码:</td>
                        <td class="right"><input type="password" name="Pass"></td>
                    </tr>
                    <tr>
                        <td class=“left” width=40% align="right">性 别:</td>
                        <td class="right"><input type="radio" id="1" name="ssex"
                            value="nan" /><input type="radio" id="2" name="ssex"
                            value="nv" /></td>
                    </tr>
                    <tr>
                        <td class=“left” width=40% align="right">学历:</td>
                        <td><select id="selc" name="place">
                                <option value="benke">本科</option>
                                <option value="zhuanke">专科</option>
                                <option value="shuoshi">硕士</option>
                                <select></td>
                    </tr>
                    <tr>
                        <td class=“left” width=40% align="right"><label for="txtarea">自我介绍:</label></td>
                        <td><textarea id="txtarea"></textarea></td>
                    </tr>
                    <tr>
                        <td class=“left” width=40% align="right">兴 趣:</td>
                        <td><input type="checkbox" id="cbox1" name="dushu" value="c1">读书
                            <input type="checkbox" id="cbox2" name="yundong" value="c2">运动
                            <input type="checkbox" id="cbox3" name="chihe" value="c3">吃喝
                        </td>
                    </tr>
                    <tr>
                        <td class=“left” width=40% align="right">头像:</td>
                        <td><input type="file" name="shangchuan" /></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td class=“left” width=40% align="center" rowspan=2><input
                            type="submit" value="提 交" /> <input type="reset" value="重 置" />
                    </tr>
                </tbody>
            </table>

        </form>

 

2.用户登录验证jsp

     1.jsp

<form action="2.jsp" method="get" > 

 <table border="1">
<tbody> 
<tr><th align="center">用户登录</th></tr>
<tr ><td  >
姓 名:</td> 
<td ><input  type="text" name="name" /></td> 
</tr> 
<tr><td >密 码:</td> 
<td ><input  type="password" name="paw" /></td> 
</tr> 
<tr><td>
</td> 
<td class=“left” width=40% align="center" rowspan=2> 
<input type="submit" value="提 交" />  <input type="reset" value="重 置" /> 


</tr> 

</tbody> 
</table> 

</form> 

   

    2.jsp

<%   String name=request.getParameter("name"); 
       String paw=request.getParameter("paw"); 
       session.setAttribute("name",name);  
       session.setAttribute("paw",paw); 
       %>
       姓名:<%=name%>  
       密码:<%=session.getAttribute("paw") %>

 

3.图书类

Book.java

 

public class Book {

    private String name;
    private String author;
    private double price;
    private int amount;
    public Book(String name, String author, double price, int amount) {
        super();
        this.name = name;
        this.author = author;
        this.price = price;
        this.amount = amount;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    public double totalPrice(){
        return amount*price;
    }
    

}

 

 

Ebook.java

public class Ebook extends Book {

    @Override
    public double totalPrice() {
        // TODO Auto-generated method stub
        return (super.totalPrice())/3;
    }

    public Ebook(String name, String author, double price, int amount) {
        super(name, author, price, amount);
        // TODO Auto-generated constructor stub
    }
    

}

 

BookTest.java

public class BookTest {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Book book=new Book("Java", "张三", 30, 2000);
        Book ebook=new Ebook("Java", "张三", 30, 2000);
        System.out.println(book.totalPrice());
        System.out.println(ebook.totalPrice());    
        System.out.println(book.totalPrice()+ebook.totalPrice());
    }

}

 

4.水仙花

shuixian.java

public class shuixian
{
 /**
  * 题目:打印出100-999之间所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身。
  * 例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方。 
     * 1.程序分析:利用for循环控制100-999个数,每个数分解出个位,十位,百位。*
  */
 public static void main(String[] args) 
 {
  for(int i=100;i<=999;i++)
  {
   int geWei,shiWei,baiWei;
   baiWei=i/100;
   shiWei=(i-baiWei*100)/10;
   geWei=i-baiWei*100-shiWei*10;
   if(i==geWei*geWei*geWei+shiWei*shiWei*shiWei+baiWei*baiWei*baiWei)
   {
    System.out.println(i);
   }
  }
 }
}

 

5.编写程序,显示从200到300之间能被3或4整除,但不能被两者同时整除,每行显示10个.

 

public class Test 
{
    public static void main(String[] arg)
    {
        int count=0;    //统计输出的个数,每10次清零轮回
        for(int i=200;i<=300;i++)
        {
            if(i%3==0)
            {
                if(i%4!=0)
                {
                    count++;
                    System.out.print(i+" ");
                }
            }
            else if(i%4==0)
            {
                count++;
                System.out.print(i+" ");
            }
                 
            if(count==10)
            {
                count=0;
                System.out.println();//10次轮回,换行清零
            }
        }
    }
}

 

 6.输出1到1000中被7整除或者以7节为的书,每行显示5个

 

 

  int sum = 0; 
  int count = 0; 
  System.out.println("1-1000之间能被7整除的数为:"); 
  for (int i = 1; i < 1001; i++) { 
       if( i % 7== 0){    
        sum += i ;     
        count ++;     
        System.out.print(i+"\t");     
                    if(count == 5){                 
                     System.out.println();                 
                     count = 0;                 
                    }     
       }

 

 7.矩阵相乘

public class Demo01  {  
    public static void main(String[] args) {  
        // TODO Auto-generated method stub  
        int[][] a={{1,2},{3,4},{5,6}};//自己定义矩阵  
        int[][] b={{1,2,3},{4,5,6}};//自己定义矩阵  
        printMatrix(a,b);  
    }  
    static void printMatrix(int[][] a,int[][] b){   
        int c[][] = new int[a.length][b[0].length];  
          
        int x,i,j;  
        for(i = 0;i<a.length ;i++)  
        {  
            for(j = 0;j<b[0].length;j++)  
            {  
                int temp = 0;  
                for(x = 0;x<b.length;x++)  
                {  
                    temp+=a[i][x]*b[x][j];                       
                }  
                c[i][j] = temp;                  
            }  
        }  
        System.out.println("矩阵相乘后结果为");  
        for(int m = 0;m<a.length;m++)  
        {  
            for(int n = 0;n<b[0].length;n++)  
            {  
                System.out.print(c[m][n]+"\t");  
            }
        }  
    }        
}

 

 

 8.已知1900年1月1日是星期1,计算某一年的1月1日是星期几

System.out.println("输入年份:");  
Scanner  in  = new Scanner(System.in);
int year =in.nextInt();
int days = 0;
for(int i=1900;i< year;i++){
    days+=365;
    if(i%400==0||(i%4==0&&i%100!=0)){
          days++;
      }      
}

int date = days%7;
String str = new String[]{" 星期一"," 星期二"," 星期三"," 星期四"," 星期五"," 星期六"," 星期日"}[date];
System.out.println(str);

 

9.矩形面积

public class test {
     public static void main(String[] args) {
            Rectangle rect = new Rectangle(4, 5);
            System.out.println("周长=" + rect.getC() + "\n面积=" + rect.getS());
        }
}
class Rectangle {
    private double width;
    private double height;
 
    public Rectangle(double width, double height) {
        this.width = width;
        this.height = height;
    }
 
    public double getC() {
        return (width + height) * 2;
    }
 
    public double getS() {
        return width * height;
    }
 
    public double getWidth() {
        return width;
    }
 
    public void setWidth(double width) {
        this.width = width;
    }
 
    public double getHeight() {
        return height;
    }
 
    public void setHeight(double height) {
        this.height = height;
    }
}

 

10.employe

 

转载于:https://www.cnblogs.com/molip/p/7422378.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值