We are required to make a program for an accountancy company that performs taxation, accounting and auditing services to clients and charges a predetermined hourly and daily rate.
The system has to be menu based and allow for customer details for a job booking to be input, as well as separately display all current jobs that are being performed, all completed jobs, and list scheduled jobs to be completed with different menu options for each. So far I have written some of it, but I can't get the menu to work, and I'm not sure if what I am even doing is correct. I can discern what the code is doing, just not how to write a lot of it myself.
Please help if you can, it would be greatly appreciated as I want to get good marks.
Here is what I have done so far:
Adam Holmes wrote: So far I have written some of it, but I can't get the menu to work, and I'm not sure if what I am even doing is correct. I can discern what the code is doing, just not how to write a lot of it myself.
You have to TellTheDetails, and quite frankly, if you are "not sure if what [you are] doing is correct", how are we to know ???...
Anyway, what are you seeing? What are you supposed to be seeing? Any speculation on the differences? etc.
Obviously, we can't give you the exact answers to homework, but we can steer you in the right way.
What exactly is going wrong with the menu? Be specific.
It looks like you need a loop for the menu. Try coding a loop and post the result back here in a new message (that is, don't modify the original).
The menu works, I can select the different options and they display the titles etc. which all display correctly but when I enter 1 to put in the customer first name, it shows up and then terminates, and when I add a switch statement inside that (which I know is probably wrong) I can input the last name as well but it terminates after that. What I am meant to do is have a submenu "inside" the first menu selection and I'm not sure how to go about that.
I'm also not sure which kind of loop you are suggesting I should use.
Thank you for the quick responses though
EDIT: I should say, less of a submenu, and more of a continuation of inputs.
Adam Holmes wrote:So I have an assignment for my programming class at uni due in 2 days and none of it seems to make sense to me. I've looked over all the class materials and such, and I still don't get half of it.
I hate to say, but this sort of request is pretty much doomed to failure, so my advice: Tick this one off as a "FAIL" and either:
(a) Start earlier next time.
(b) Ask for help earlier next time.
I also see very little "meat" in your code, which suggests to me that you've left this far too late, because the requirements are NOT simple. We're all volunteers here, and we're all over the globe, so your "response time" will probably reflect who happens to be "up" at the time. And, as has already been said, we'll help you out, but we won't write the code for you.
All that said, my main worry is that last statement of yours: "I've looked over all the class materials and such, and I still don't get half of it".
Why not? Are the course materials bad? Is your prof a bastard? It seems insane to me to be tackling a problem that you don't have the tools to finish without letting someone at your uni know of your problems before there's only 2 days to go (a weekend no less).
If there's something specific you don't understand, we'll be happy to help; but a general "AAGH!!" is beyond even our capabilities.
Adam Holmes wrote:I can select the different options and they display the titles etc. which all display correctly but when I enter 1 to put in the customer first name, it shows up and then terminates, and when I add a switch statement inside that (which I know is probably wrong) I can input the last name as well but it terminates after that
Notice how on lines 20 -26 you printed a prompt (the menu) and then on line 31 you called scan.nextInt and the program just waited until you typed something ?
nextInt is known as a blocking method. It just sits there waiting until it has something to return and then it returns it.
If you don't have any blocking methods then the code will just keep continuing on to the next line of code until it runs out of lines of code and then it exits.
So, whenever you have a line of code that asks the user for information, you need it to be followed by another line of code that waits for that information to be entered.
Once you have all the information you need, you then have to do something with it.
Once you've done that, you need to ask the user what they want to do next. This is where the loop comes in.
As I said earlier code is executed line by line until you come to the end of the program. If you put some code in a loop then it never reaches the end of the program - it just goes back to the start of the loop.
In your case I think a while loop is the best option. Fot the moment just make it an infinite loop. We can look at how to exit from it later.
So you will end up with something like
See if you can get that working then we can look at the next step.