-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDay3.java
More file actions
63 lines (53 loc) · 1.74 KB
/
Day3.java
File metadata and controls
63 lines (53 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// ---------------------------------------------------
// Author : Benjamin Kataliko Viranga
// Community : Stunt Business
// Community website : www.stuntbusiness.com
//
// 30 Days - Q&A Java basic
// Day 3 : Challenge I - Input and user functions using the value coming from the String[] args.
// Day 3 | IG : https://www.instagram.com/benjivrik/
// ----------------------------------------------------
// what would be the output of this program ?
public class Day3
{
/**
*
* Request the user to enter a number.
* Use the integer entered by the user in the function that you are creating.
* This function return the double of the parameter.
*
*
*/
/**
* This function returns the double of your parameter
* @param value
* @return
*/
public static int double_parameter(int value)
{
return value * 2;
}
/**
* run your class here
* @param args
*/
public static void main(String[] args)
{
int user_value = 0;
// the size must be 1
if(args.length == 0 || args.length > 1)
{
// Only expect one Integer for the program to run
System.out.println("You must enter one parameter in the command line.");
}
else
{
user_value = Integer.parseInt(args[0]); //get the first parameter of the command line
// display the value entered by the user
System.out.printf("\nYou entered : %d.\n", user_value);
// return the double of the parameter
System.out.println("The double of the parameter is : " + Day3.double_parameter(user_value));
}
System.out.println("End of program.");
}
}