Question

In: Computer Science

JAVA for Dummies HELP Problem Statement: Jeff Bezos has decided to have a party at his...

JAVA for Dummies HELP

Problem Statement: Jeff Bezos has decided to have a party at his mansion, and he’s invited 50 couples. As the couples arrive at the mansion, they receive a ticket with a number (like at the deli counter), with the first couple receiving the tickets labeled 1 and 2, the second couple getting 3 and 4, and so on. Jeff has noticed in the past that when he throws parties, conversation groups most often occur in groups of 4 people. Being a nerd, he wonders: Exactly how many different conversation groups of 4 are possible at this party?

He writes himself a short Java program, and in minutes he has his answer….

(WRITE THIS PROGRAM)

(An important small hint – the person who has the ticket with a “1” on it can only (obviously) occur once in a given group – so, for example the grouping 1, 1, 2, 3 could NEVER occur!)

initialize a counter to 0;

--for each possible int value for personOne (starting at 1, ending at 100-3)

-----for each possible int value for personTwo (starting at personOne+1, ending at 100-2)

-------for each possible int value for personThree(starting at personTwo+1, ending at 100-1)

--------for each possible int value for personFour(staring at personThree+1, ending at 100)

increment the count output the result;

Solutions

Expert Solution

public class Groups {
   public static void main(String[] args) {
       int numGroups = 0;
      
       for(int p1 = 1; p1 <= 100-3; p1++) {
           for(int p2 = p1 + 1; p2 <= 100 - 2; p2++)
               for(int p3 = p2 + 1; p3 <= 100-1; p3++)
                   for(int p4 = p3 + 1; p4 <= 100; p4++)
                       numGroups++;
       }
      
       System.out.println("The number of different groups of 4 that can be formed is " + numGroups);
  
   }
}


output
-------
The number of different groups of 4 that can be formed is 3921225


Related Solutions

Jeff Bezos -Amazon What has he done with his wealth? What is his approximate net worth?...
Jeff Bezos -Amazon What has he done with his wealth? What is his approximate net worth? Where does he rank among the world’s richest people? Any other “fun facts” that you find interesting
Suppose that Jeff has a US quarter and a US nickel. Jeff believes that his US...
Suppose that Jeff has a US quarter and a US nickel. Jeff believes that his US quarter is more likely to land heads than his US nickel. Suppose Jeff flips his quarter 100 times and gets 51 heads, and Jeff independently flips the nickel 100 times and gets 49 heads. (a) Construct a 99% confidence interval for the difference in the proportion of times Jeff’s quarter lands heads and the proportion of times Jeff’s nickel lands heads. (b) If Jeff’s...
Jeff has learned from his urologist that his kidney disease has progressed to renal failure and...
Jeff has learned from his urologist that his kidney disease has progressed to renal failure and that he must include dialysis in his treatment plan. Because you work on the dialysis unit of the hospital, Jeff has asked you to explain how the hemodialysis machine works. He also asks if the unit is portable so that he can use it at home, if necessary. What will you tell Jeff?
Q2. The patient with a tumor in his brain has decided to have an operation in...
Q2. The patient with a tumor in his brain has decided to have an operation in a private hospital. The hospital has two professors, one professor and the other an associate professor. The patient received data from patients who had surgery on doctors in the past and saw some statistics. There are three alternatives awaiting him after the surgery, such as recovery, temporary partial paralysis and death. 8% of the patients that the professor had previously operated on healed, and...
You and your roommates have decided to go to a fraternity party on Saturday night. You...
You and your roommates have decided to go to a fraternity party on Saturday night. You arrive at the fraternity house and see another classmate, Jenn, from your psychology class. You go over to say hello and see what she thought of the first exam, but Jenn seems to be acting very strangely. She starts describing fantastic colors made by the lights and how the dance floor is a beautiful sea of diamonds. You take a look around and realize...
Third-party access has become a big problem as the security of the third-party plays a critical...
Third-party access has become a big problem as the security of the third-party plays a critical role in ensuring the security of the primary. How can this situation be handled best? Can A third-party can be both an internal and external threat.
Arthur, the ruler of Avalon, has asked for your help with the economy of his country....
Arthur, the ruler of Avalon, has asked for your help with the economy of his country. Arthur's economic minister provides you with the following information: Work-eligible population: 30 million Labor force: 24 million Employed people: 21 million Frictionally unemployed people: 2 million Structurally unemployed people: 1.5 million Arthur would like to know whether his kingdom is enjoying an expansion or suffering a recession. See if you can advise him. Give all numeric answers to two decimals. King Arthur, right now...
Dr. Jeff Jones has been a counselor in private practice for over five years. His office...
Dr. Jeff Jones has been a counselor in private practice for over five years. His office is in a suite of offices in downtown Chicago. The other offices are occupied by other mental health professionals. Dr. Jones treats adolescents and adults in his practice and often works from early in the morning to early evening. In recent weeks, Dr. Jones has been experiencing severe marital problems, difficulty sleeping, and difficulty relaxing. He often takes a drink or two in the...
You have decided that your company has outgrown the warehouse described in the previous problem. You...
You have decided that your company has outgrown the warehouse described in the previous problem. You have received an offer from someone willing to purchase the warehouse for $1,200,000. If you accept this offer, how much money will you have left over from the sale after you have paid off the balance of the loan? As a reminder, the original loan was a 15-year, 6% APR (monthly) loan with monthly payments with an original amount borrowed of $1,500,000. You have...
The Federal Reserve has recently decided to increase interestrates to help reduce future inflation. t/f
The Federal Reserve has recently decided to increase interest rates to help reduce future inflation. t/f
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT