Okay well, i need to make a program to withdraw an indicated (user-input) amount from a bank account. Set the beginning balance as $10,000 and set up the program so that if the withdrawal amount is less than 0 or greater than $10,000 it will trigger an assertion error but i am having some troubles.
I have this:
import java.util.Scanner;
public class Project2
{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
System.out.print("Available balance: $10,000. Please input the amount you want to withdraw: ");
int num = input.nextInt();
assert(num <= 0 || num >= 10000):
System.out.printf("Invalid amount", num);
}
}
But when i enter a number that is less then zero it does not give me my assertion error, and when i put in a number larger then 10,000 it also does not give my assertion error. What am i doing wrong?