-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaStatements.java
More file actions
27 lines (20 loc) · 907 Bytes
/
JavaStatements.java
File metadata and controls
27 lines (20 loc) · 907 Bytes
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
import java.util.Scanner;
public class JavaStatements {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// a) Declare variables
int c, thisIsAVariable, q76354, number;
// b) Prompt the user to enter an integer
System.out.print("Enter an integer: ");
// c) Read an integer and store in variable value
int value = input.nextInt();
// d) Print "This is a Java program" on one line
System.out.println("This is a Java program");
// e) Print "This is a Java program" on two lines
System.out.printf("%s%n%s%n", "This is a Java", "program");
// f) If number is not equal to 7, print a message
System.out.print("Enter a number: ");
number = input.nextInt();
if (number != 7) System.out.println("The variable number is not equal to 7");
}
}