DigitSum and Multiple Of Seven


Submit solution

Points: 50 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem types

題目說明

請使用digitSum方法相加所有位數的數值,並使用isMultipleOfSeven方法判斷相加後的數值是否是7的倍數,最後在main方法印出結果(會檢查)

請務必依照下方程式碼模板作答,不得修改主程式的結構,否則不予計分!

程式碼模板 (請務必依照此模板撰寫)

import java.util.Scanner;

public class NumberDigitSum {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        //呼叫digitSum、isMultipleOfSeven方法
        //印出輸出結果

    }

    public static int digitSum(int n) { 

        // 計算各個位數的數值總和(記得return)

    }

    public static boolean isMultipleOfSeven(int n) { 

        // 判斷是否為 7 的倍數(記得return)

    }
}

輸入

整數

輸出

所有位數相加後的整數是否為7的倍數
是則顯示true
否則顯示false

範例輸入 #1

1245

範例輸出 #1

12 false

範例輸入 #2

49753

範例輸出 #2

28 true

說明:4+9+7+5+3=28,為7的倍數所以顯示true


Comments

There are no comments at the moment.