Reputation: 48 Craftsman
- Active Members
- Active Posts:
- 254 (0.14 per day)
- 04-February 10
- Profile Views:
- Last Active:
- Feb 26 2014 05:37 AM
- OS Preference:
- Who Cares
- Favorite Browser:
- Favorite Processor:
- Who Cares
- Favorite Gaming Platform:
- Your Car:
- Dream Kudos:
Posts I've Made
Posted 19 Feb 2014I would suggest doing some searching around before asking this, the internet has many examples of a credit card account.
But I suggest breaking it down to what has been asked:
You know you will have to have 7 customers
You know you need to ask the customer for 5 pieces of information,what can you use to get this information from a customer?
You know that if -1 is entered it will close the program.
and so on...
Then just work out what you will need to get each of these particulars done, prompt user for input and use the scanner class to save to a variable?
Get the pen and paper out and read it carefully, breaking it down makes it a lot easier than been overwhelmed with a full paragraph of blah.
This post may help you understand a bit more about some (but not all) of what you could do.
Posted 19 Feb 2014because intFuelgauge is an int, your handing it a string
I do not know enough about blueJ but from the image that is what has happened, change it to an int and see what happens, my though is it will run fine but?
Posted 19 Feb 2014referring to first post why not put your JOptionPane in a method and use a switch and if it is wrong have it call the JOptionPane again after displaying a default error message?
Posted 19 Feb 2014Have you tried making a little test harness to see what happens?
It looks like it will run but what are you passing as the object?
Car car = new Car(); Car car2= new Car("ford", "red", 10);
These should work.
But as salazar says more information for a better answer.
Posted 11 Feb 2014With this line:
myOption = kb.nextInt();
it is easy enough to check for a negative number using if (myOption < 0).
If you want to allow the user to enter a letter "a" then you'll need to switch to reading a string input using nextLine() (unless you want to use error handling or perhaps hasNextInt()).
Once you've read this string-input you can try to parse it as an integer.
A simplistic solution is just to look for a specific exit-value such as -99.
More specific to the question than my solution.
- Member Title:
- D.I.C Regular
- Age Unknown
- Birthday Unknown
- some page on the web
- Reading,Gardening,Computers,Cooking,Soccer,Anything tech.
- Years Programming:
- Programming Languages:
Learner of all languages.
Current main interest PHP,Java,Web Development
Anything and everything.
- Click here to e-mail me