Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: I don't understand this. Please help...

  1. #1
    Member
    Join Date
    Jun 2014
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default I don't understand this. Please help...

    the year is 2013. the CEO appointed new managers of accounts,finance,sales. the term for the accounts manager is 4 years, the term for the finance manager is 5 years and the term for the sales manager is 8 years. Write a java program to determin and print the next year in which new managers will be appointed for all three departments.

    this is my code so far:

    import java.util.*;
    public class Program1{
    	public static void main (String [] args){
    		Scanner in = new Scanner (System.in);
    int year=2013,acc=2013,fin=2013,sales=2013;
    for(year=2013;year <= 2017;year ++) acc ++;
    for(year=2013;year <= 2018;year ++) fin ++;
    for(year=2013;year <= 2021;year ++) sales ++;
     
    System.out.printf("The new Accounts manager will be appointed in the year: %d\n",acc);
    System.out.printf("The new Finance manager will be appointed in the year: %d\n",fin);
    System.out.printf("The new Sales manager will be appointed in the year: %d\n",sales);
    	}
    }


  2. #2
    Junior Member
    Join Date
    Jun 2014
    Location
    Auburn, Alabama
    Posts
    5
    My Mood
    Inspired
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I don't understand this. Please help...

    The program prints out the correct year for when someone new is supposed to be appointed for all of the offices. What is the problem?

  3. #3
    Member
    Join Date
    Jun 2014
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: I don't understand this. Please help...

    Quote Originally Posted by jamalh1 View Post
    The program prints out the correct year for when someone new is supposed to be appointed for all of the offices. What is the problem?
    Yeah it prints the correct year for each of the different managers.But i think i interpreted the question wrong because it says "print the next year in which new managers will be appointed for all three departments" With emphasis on the word year. So i dont understand how to code that.

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: I don't understand this. Please help...

    It's a least common multiple (LCM) problem. All 3 managers were appointed in 2013 and will each be replaced in 4, 5, and 8 year intervals from 2013. The problem is asking you to write a program that will compute the next year (like 2013) in which all managers will be replaced. Find the LCM of 4, 5, and 8 and add to 2013 to find the answer.

Similar Threads

  1. I don't understand what's wrong in my programme
    By si3012 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 16th, 2013, 07:58 AM
  2. [SOLVED] Don't understand why it loops through multiple times...
    By Discoveringmypath in forum Loops & Control Statements
    Replies: 4
    Last Post: January 26th, 2013, 09:00 PM
  3. Don't understand void methods, need help!
    By alex067 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 9th, 2012, 07:02 AM
  4. Simply don't understand minimax...
    By Herah in forum Algorithms & Recursion
    Replies: 3
    Last Post: October 13th, 2011, 12:45 PM
  5. I don't understand what I'm supposed to do
    By dmcettrick in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 11th, 2011, 09:34 AM