雲課堂javaweb微專業Java基礎測試題

來源:互聯網
上載者:User

標籤:

 

第1章編程題1溫度轉換

題目內容:

寫一個將華氏溫度轉換成攝氏溫度的程式,轉換的公式是:

    °F = (9/5)*°C + 32

其中C表示攝氏溫度,F表示華氏溫度。

程式的輸入是一個整數,表示華氏溫度。輸出對應的攝氏溫度,也是一個整數。

提示,為了把計算結果的浮點數轉換成整數,需要使用下面的運算式:

    (int)x;

其中x是要轉換的那個浮點數。

輸入格式:

一個整數。

輸出格式:

一個整數。

輸入範例:

100

輸出範例:

37

時間限制:500ms記憶體限制:32000kb
 1 import java.util.Scanner; 2  3 public class Main { 4      5     /** 6      * fahrenheit 華氏溫度 7      * celsius  攝氏溫度 8      *  9      * */10     public static void main(String[] args) {11         // TODO Auto-generated method stub12         Scanner in = new Scanner(System.in);13         int fahrenheit = in.nextInt();14         int celsius= (int)((fahrenheit-32)*(5/9.0));15         System.out.println(celsius);16     }17 }

 

雲課堂javaweb微專業Java基礎測試題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.