Please see the attached file. Thank You.

1. Write a C++ program (or Java program) called practice1_1.cpp (or practice1_1.java) that reads input numbers from a user and displays the number that occurs most frequently among all the input numbers.

Input format: This is a sample input from a user.

-7

20

15


The first number (= 5 in the example) indicates that there will be five integer numbers in the input. Then, all numbers from the second line (= 7 in the example) to the last line (15 in the example) are actual numbers. Thus, your program should read them and display the most frequent number among 7, -7, 20, 7, and 15. Because the number 7 appears twice in the input, your answer should be 7. If you have more than one number that occurs most often, you have to display the largest number.

Sample Run 0: Assume that the user typed the following lines.

-7

20

15

This is the correct output of your program.

Number:7

Frequency:2

Sample Run 1: Assume that the user typed the following lines.

10

-1

20

-15

72

20

20

30

This is the correct output of your program. Note that the frequencies of 5 and 20 are 3. But since 20 is bigger than 5, the correct number should be 20.

Number:20

Frequency:3

Sample Run 2: Assume that the user typed the following lines. This is the correct output of your program.

Number:2

Frequency:1

2. Write a C++ program (or Java program) called practice1_2.cpp (or practice 1_2.java) that reads two groups of numbers in which each group has several integer numbers without duplicates. Your program should display the non-common numbers in both groups in the descending order.

Input format: This is a sample input from a user.

20

-7

15

14


The first number (= 5 in the example) indicates that there are five numbers in the first group. Then, the numbers from the second line (= 7 in the example) to the sixth line (15 in the example) are actual numbers of the first group.

The following number (= 3 in the example) indicates that there are three numbers in the second group which are 8, 14, and 7.

For the input, your program should present the non-common numbers in both groups in the descending order. Note that both 7 and 8 are common numbers in the two groups. Thus, you have to display the non-common numbers (= 20, 15, 14, -7) in the descending order on the screen. If there’s non-common number, your program should display NONE.

Sample Run 0: Assume that the user typed the following lines.

20

-7

15

14

This is the correct output of your program.

Answer:20 15 14 -7

Sample Run 1: Assume that the user typed the following lines.

-5

-5

This is the correct output of your program.

Answer:NONE

Sample Run 2: Assume that the user typed the following lines.

-5

-5

This is the correct output of your program.

Answer:3

3. Write a C++ program (or Java program) called practice 1_3.cpp (or practice 1_3.java) that reads a number of elements in a set and then read the elements of the set. After that, your program should display all possible binary numbers and corresponding subsets one by one. For the program, you can assume that the number of elements in a set is less than or equal to 10.

Sample Run 1: Assume that the user typed the following input. Note that there are three elements in the set with the elements A, B, and C.

A B C

This is the correct output.

000:EMPTY

001:C

010:B

011:B C

100:A

101:A C

110:A B

111:A B C

The first line shows that the binary number is “000”. Note that the first bit ‘0’ is for the element ‘A’, the second bit ‘0’ for the element B, and the last bit ‘0’ for the element C. Since all three bits are ‘0’, the binary number “000” means the empty set. The next line indicates that the binary number is “001” and it corresponds to the subset {C} because only the last bit is ‘1’. Similarly, the last line indicates that the binary number is “111” and it corresponds to the subset {A, B, C} because all bits are ‘1’. Sample Run 2: Assume that the user typed the following input.

CST238 CST370

This is the correct output.

00:EMPTY

01:CST370

10:CST238

11:CST238 CST370

Sample Run 3: Assume that the user typed the following input. This is the correct output of your program.

0:EMPTY

CST370 Page 5 of 5 Homework 1