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
How does Amazon CEO Jeff Bezos Achieve Cultural Diversity and what are his best practices and...
How does Amazon CEO Jeff Bezos Achieve Cultural Diversity and what are his best practices and initiatives for achieving cultural diversity in the organization? For example, does his executive board contain any minorities? Explain which leadership practices were successful in diversity efforts and which practices needed improvement.
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.
Problem Statement Josephus attended a party where they had a rather strange raffle. Everyone was to...
Problem Statement Josephus attended a party where they had a rather strange raffle. Everyone was to stand in a circle, and every Mth person was to be eliminated until only one person was remaining, who won the lawnmower. Write the function Josephus, which takes as parameters a vector<string> representing the N guests at the party in the order they line up for the raffle, and the integer M, giving which person will be eliminated at each turn. Your function should...
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...
Question: Properly convert the solution to this problem from Java to C++ Problem Statement If you...
Question: Properly convert the solution to this problem from Java to C++ Problem Statement If you want to write a message anonymously, one way to do it is to cut out letters from headlines in a newspaper and paste them onto a blank piece of paper to form the message you want to write. Given several headlines that you have cut out, determine how many messages from a list you can write using the letters from the headlines. You should...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT