In the line discount = bd; bd holds no value. You need to initialize bd before assigning it to another variable.