Can anyone help me write a program in java that:

Has a user enter their name
then enter their last 4 weeks hours worked

Then have it display the:
-total hours worked
-average hours per week
-full time equivalent:
2 weeks
3 days
7 hours

This would help me out a bunch. I hope someone can help me with this. I will appreciate any positive feedback!

8 Years
Discussion Span
Last Post by nandomendoza

This is the code i have so far. Any suggestions

public class Program1
       public static void main(String[] args)
           //This asks user to enter their name.

           String name;
           System.out.println("Please enter your name: ");
           name = SavitchIn.readLine();

           //This asks the user to input the hours worked in integers.

           int hours1;
           int hours2;
           int hours3;
           int hours4;

           System.out.println("Please enter the last 4 week's hours worked (integers): ");
           hours1 = SavitchIn.readInt();
           hours2 = SavitchIn.readInt();
           hours3 = SavitchIn.readInt();
           hours4 = SavitchIn.readInt();

           int sum = hours1 + hours2 + hours3 + hours4;

           System.out.println("Total hours worked " + sum);


Edited by Reverend Jim: Fixed formatting


Yes, Next time you post wrap your code inside
[code=java] and [/code] tags. Also what do you need help for ? Tell us the problem (compile errors,logic problems etc etc) you are facing and this time please do not give the reason "I am a beginner" for not attempting something.:)


This is the code i have for the beginning of this program. I now need to take the hours that have been worked and have them result in an average of hours worked. I know mathematically how to figure it our but how do I place it in code?


how do I place it in code?

Thats what I meant by try it. Trust yourself a little and take the jump. At most you will get a compile error or a wrong output, the world will not end with that.
The help offered here is more like if your car has a problem we will help you sort it out, but we will not push / drive the car for you.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.