-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasicIfStatement.java
28 lines (22 loc) · 1.1 KB
/
BasicIfStatement.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
/**
* If you sold more than 500,000 goods then you get a bonus of $10,000!
* Or else you get $0 because you under-sold. Be careful of where you put
* your scanner inputs and your initial values. This is only a one-way if statement. If
* you sold below the 500,000 goods then the program terminates
*/
import java.util.Scanner;
public class BasicIfStatement {
public static void main(String[] args) {
int bonus = 0; // Go ahead and declare and initialize bonus, just cuz
Scanner input = new Scanner(System.in); //Get ready for input
System.out.print("How many goods did you manage to sell? : "); //Prompt user for input
int goodsSold = input.nextInt(); // Declaring the input as int goodsSold
if (goodsSold > 500000) { //If the amount of goods you sold is true for greater than 500,00
bonus = 10000; // then you add a value to bonus!
System.out.println("Congratulations! You get a bonus of $" + bonus); //Display bonus
/**Make sure you keep all components that pertain to the if statment
* within its corresponding if-statment {} curly brackets
*/
}
}
}