-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSameValues.java
32 lines (19 loc) · 918 Bytes
/
SameValues.java
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
/* Write an application to accept an integer number and a double number from the user,
* then shows an output of same result after dividing each by 5.
Example: inputting: 3 and 3.0 outputting: 0.6 and 0.6 */
import java.util.Scanner;
class SameValues {
public static void main(String[] args) {
int num1;
double num2;
Scanner input = new Scanner(System.in);
System.out.print("Enter an Integer number: ");
num1 = input.nextInt();
System.out.print("Enter a double number: ");
num2 = input.nextDouble();
System.out.println("divided by 5: " + ((double)num1/5));
// we took the number as a integer but in the assignment it says result be 0.6 (double).
// I searched and I found casting.
System.out.println("divided by 5: " + (num2/5));
}
}