Question
I have a question about my computer science homework. One of the things it asks me to do is create a boolean charge method that
I have a question about my computer science homework. One of the things it asks me to do is create a boolean charge method that will return true or false based on the value of variables price and limit. These are the directions:
initial balance to 0 and limit to 10000, choose whatever value you want to initial the other data fields
The charge method will remove price from limit and decrease the balance (when you own money, you have a negative balance), this operation will be rejected if price exceed limit
And this is what I have:
public boolean charge(double price) { if( price <= limit) { limit -= price; balance -= price; return true; }else if (price > limit){ return false; } }
I'm getting an error message where it is saying that it needs a return statement but I have a return statement. What is the issue here? Java please and let me know if you need any other information.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started