Weeks to Days
Easyjava
Learn the Concept: ConstantsDeclare final int DAYS_PER_WEEK = 7; and use it to convert weeks into days.
Input: one whole number — the number of weeks.
Output: one line — the number of days.
Example 1
Input
3
Output
21
- 0 <= weeks <= 1000000
Hint 1
Multiply the input by the constant.
Hint 2
Using the named constant makes the formula self-explanatory.
The number 7 is fixed, so naming it DAYSPERWEEK with final documents the code and prevents accidental change. The conversion is a single multiplication.
Submit an attempt to unlock the solution. (Sign in first.)
Related Problems
- Circle Area with a PI ConstantEasy · javaSolve Problem
- Final Price with a Tax ConstantEasy · javaSolve Problem
- Seconds in N DaysEasy · javaSolve Problem