Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Java Problems

  Asked By: Nicole    Date: Feb 25    Category: Java    Views: 779
  

I have been given a set of problems to do as extra work and two of
them I haven't been able to complete let alone even start. I was
wondering if anyone could please help me with them? Below are the two
problems:

1) Write a program that determines the additional state tax owed by
an employee. The state charges a 4% tax on net income. Determine net
income by subtracting a $500 allowance for each dependent from gross
income. Your program will read gross income, number of independents,
and tax amount already deducted. It will then compute the actual tax
owed and tax deducted, followed by the message "Send check"
or "Refund", depending on whether the difference is positive or
negative.

2) Suppose you own a beer distributorship that sells Piels (ID
number1), Coors (ID number2), Bud (ID number3), and Iron City (ID
number4) by the case. Write a menu driven program to do the following:
a. Enter the case inventory for each brand for the start of the week
b. Purchase beer- the amount of cases of beer purchased for each
brand in a week
c. Sell beer- the amount of cases of beer sold for each brand in a
week
d. Display inventory- process all weekly sales and purchase records
for each brand and print the final inventory on screen.
e. Quit the program by entering a sentinel value.

Half the code needed for these two problems I haven't learnt yet and
I haven't been given any formula's either. I have only learnt very
basic java so far. Please if anyone could help me in anyway i would
really appreciate it.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Alfonsine Miller     Answered On: Feb 25

The problem here is that Assignments and assessments are normally
designed to teach you certain skills ... skills that are essential in
/your/ development as a programmer. If someone else where to do the
majority of /your/ code, then they have learned the lesson and /you/
have learned nothing.

The formula for both examples is given to you, but not in a clear cut
Formula a = x+y^2 kind of way. You have to pull apart the formula from
the specs ...

As for the code, assuming that it is all from the command line, or your
school uses some sort of GUI helper for the GUI ... it really isn't that
advanced.

After a very brief overview of the two problems  all you really need to
do use if/else blocks, loops and read  in and write  out the System.in and
System.out. It won't be pretty, but it will work.

What I would do if I where you, is to identify each of the tasks on a
sheet of paper (like, Task 1: A user must be able to enter  their wage
(That isn’t written in your problem, but I assume that the user enters
in their wage)). Continue pulling out all of the Tasks until you don’t
think there are any left, don’t try and force a task out of it though,
at least not yet.

After you have done that, look though your tasks. Identify which task
simply has to be done first (probably getting the wage in), then try and
find what you think the next most important task is going to be
(probably finding out how many dependants they have) and so on until you
think you have identified which order you should do everything.

Now load up your .java editor of choice and build up your class file.
Write your program  to satisfy the first task and no more. Write some
sort of test to make sure that it got in somewhere (putting it to
System.out is always an easy way of doing that). Once that is working,
put that task down, and move to the next task and so on.

If you look at an entire problem, it is easy to get overwhelmed, if you
break it up into simple chunks it gets much easier.

 
Didn't find what you were looking for? Find more on Java Problems Or get search suggestion and latest updates.




Tagged: