Board logo

標題: 題目2_英哩轉公里 [打印本頁]

作者: may    時間: 2020-10-17 16:01     標題: 題目2_英哩轉公里

試撰寫一程式,可由鍵盤輸入英哩,程式的輸出為公里,其轉換公式如下:
1 英哩= 1.6 公里

輸入說明
輸入欲轉換之英哩數(int)。

輸出說明
輸出公里(double),取到小數點以下第一位。

Example(程式結果下載)

Sample Input:        Sample Output:
90
95        144.0
152.0
資料來源:線上協同學習平台
作者: 洪子涵    時間: 2020-10-17 16:59

本帖最後由 洪子涵 於 2020-10-17 17:16 編輯
  1. import java.util.Scanner;
  2. public class AA {
  3.         public static Scanner s = new Scanner(System.in);
  4.         public static void main(String[] args) {
  5.                 int a=s.nextInt();
  6.                 System.out.println(1.6*(double)(a));
  7.         }


  8. }
複製代碼

作者: 洪藜芸    時間: 2020-10-17 17:20

  1. import java.util.Scanner;
  2. public class ccccc {
  3.         public static void main(String[] args){
  4.                 Scanner c=new Scanner(System.in);
  5.                 float e=c.nextFloat(),e2=c.nextFloat();
  6.                 double k,k2;
  7.                 k=e*1.6;
  8.                 k2=e2*1.6;
  9.                 System.out.printf("%.1f%n%.1f%n",k,k2);
  10.         }
  11. }
複製代碼

作者: 陳弘修    時間: 2020-10-17 17:21

package ch01;

import java.util.Scanner;

public class ch02 {
        public static void main(String[] args) {
                Scanner src = new Scanner(System.in);
                int a =src.nextInt();
                int b =src.nextInt();
                System.out.println(a + "英里為" + a * 1.6 + "公里");
        System.out.println(b + "英里為" + b * 1.6 + "公里");
               
        }
}
作者: 蔡依宸    時間: 2020-10-17 17:24

  1. import java.util.Scanner;
  2. public class Ch17 {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.               Scanner c = new Scanner(System.in);
  6.           int a =c.nextInt();
  7.           int b =c.nextInt();
  8.           System.out.println(a + "英里為" + a * 1.6 + "公里");
  9.   System.out.println(b + "英里為" + b * 1.6 + "公里");
  10. }
  11.   }
複製代碼

作者: 蔡季庭    時間: 2020-10-17 17:27

  1. import java.util.Scanner;
  2. public class GG {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.                 Scanner s = new Scanner(System.in);
  6.                 int x =s.nextInt();
  7.                 int y =s.nextInt();
  8.                 System.out.println(x + "英里為" + x * 1.6 + "公里");
  9.                 System.out.println(y + "英里為" + y * 1.6 + "公里");
  10.         }
  11. }
複製代碼

作者: 陳智鈞    時間: 2020-10-17 17:30

  1. import java.util.Scanner;
  2. public class Ch01 {
  3.         public static Scanner s = new Scanner(System.in);
  4.         public static void main(String[] args) {
  5.                 int a=s.nextInt();
  6.                 System.out.println(1.6*(double)(a));
  7.         }
  8. }
複製代碼

作者: 戴偉宸    時間: 2020-10-24 16:59

  1. import java.util.Scanner;
  2. public class A {
  3.         public static Scanner s = new Scanner(System.in);
  4.         public static void main(String[] args) {
  5.                 int a=s.nextInt();
  6.                 System.out.println(1.6*(double)(a));
  7.         }
  8. }
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/) Powered by Discuz! 7.2