Java - 如果标记大于10,如何将标记设置为0?

时间:2017-05-06 11:50:03

标签: java

我被问题要求将标记设置为0,如果它超过10 ...这是我的问题:“实际标记不应超过10.如果给出的标记无效,则实际标记应设为0.“任何人都可以帮我如何设置???

 public void setPractical(double practical_mark)
{
    Scanner read = new Scanner(System.in);
    System.out.println("Enter the practical_mark");
    practical_mark =read.nextDouble();
  if ( practical_mark>10)
  {
      practical_mark = 0;                                                                 
  }   
}

1 个答案:

答案 0 :(得分:4)

您的解决方案是正确的,您必须返回值:

MultipartRequest multi = new MultipartRequest(request, "C:\\Users\\HP\\workspace\\Project_OnlineExa\\WebContent"); 

然后应该像这样使用结果:

 <style type="text/css">
    @media screen and (max-width : 480px){
      div.menu ul {
         display: inline-block;
         width: 85%;
        display: inline-block;
        padding-bottom:20px;
        white-space: nowrap;
        overflow-y: hidden;
        overflow-x: scroll; 
        -webkit-overflow-scrolling: touch; 
        -ms-overflow-style: -ms-autohiding-scrollbar;
      }
      div.menu li {
          display: inline-block; 
       }
      div.menu li a {
        text-align: center;
      }
    }
    </style>
    <nav role="navigation" class="site-navigation main-navigation">
      <div class="menu">
        <ul>
          <li class="page_item page-item-40"><a href="http://localhost/property_abba/for-sale/">Buy</a></li>
          <li class="page_item page-item-41"><a href="http://localhost/property_abba/for-rent/">Rent</a></li>
          <li class="page_item page-item-7"><a href="http://localhost/property_abba/sell/">Sell</a></li>
          <li class="page_item page-item-9 current_page_item"><a href="http://localhost/property_abba/valuations/">Valuations</a></li>
          <li class="page_item page-item-15"><a href="http://localhost/property_abba/property-management/">Property Management</a></li>
          <li class="page_item page-item-11"><a href="http://localhost/property_abba/about-us/">About Us</a></li>
          <li class="page_item page-item-13"><a href="http://localhost/property_abba/contact-us/">Contact Us</a></li>
        </ul>
      </div>
    </nav>

修改

就像@Shashwat在评论中提到的,如果你想改变方法中的值,那么为什么你像方法中的参数一样传递它,它是无用的,你可以使用:

<TextView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:textColor="@color/white"
       android:fontFamily="monospace"
       android:typeface="monospace"
                                  />