CHM341-EXAM_2_Fall24-1.pdf
CHM341-EXAM_3_Fall24_F-1.pdf
CHM341-EXAM_3_Fall24_F-1.pdf
You are given a sheet for work. Fill it out and be sure to…
You are given a sheet for work. Fill it out and be sure to include your Exam ID. If you do not turn this sheet in before you leave, you could get a zero for the final.
Your exam ID is: YNCH Write that in the “Exam ID” space on y…
Your exam ID is: YNCH Write that in the “Exam ID” space on your sheet.
Use IntelliJ to write a Java program named “PopularVacation”…
Use IntelliJ to write a Java program named “PopularVacation” that follows the instructions below. When your program is complete, copy your program in Intellij and paste it in the text box below. Also please follow good programming style practices and include comments along with your code for full credit! Problem Description: The winter break is upon us and online platforms for booking vacation packages would like to analyze people’s preferences for travel destinations. You are going to write a program that analyzes customer preferences for popular vacation packages during the year. Follow the instructions below to code the “PopularVacation” program. main Method: Calls the getNumVacationPacks method to get the number of vacation packages to be processed. Calls the getVacationPacksNames method to get the filename containing the vacation package names. Pass the number of vacation packages as a parameter. Calls the writeVacationPrefData method to get all vacation packages’ preference data filename. Pass the filename containing the vacation package names as a parameter. Prints the name of the file containing vacation packages preferences data on the console. Output Example: The file containing Vacation Packages Preferences data is: VacationPackagePreferred.txt Other Methods: getNumVacationPacks method takes no input arguments reads the number of vacation packages to be presented to a customer, as input from the user. Verify the number is between 1 and 10, both inclusive. returns number of vacation packages to be managed by the vacation booking software. getVacationPacksNames method Example: for a number of vacation packages = 4 and appropriate user inputs, the file has: takes one input argument: number of vacation packages reads the name of the output file from the user into the variable filename1. reads the names of vacation packages / travel destinations from the user. Each name should be written to the file of the chosen EuropeCaribbeanAlaska Southeast Asia Returns the filename1. genVacationPrefData method takes no arguments generates 12 months of random number of customer preferences (between 1 and 100, both inclusive) for the input vacation package and stores them into an array. Hint: Random integer generation can be done as: int randomNum = (int)(Math.random() * (max-min+1)) + min; Example: The array may have the following monthly preferences: {24, 45, 38, 42, 100, 56, 87, 76, 3, 55, 81, 20} returns the array of generated preferences for the vacation package. writeVacationPrefData method Continuing the previous Example the file, filename2, will have: takes one input argument: the filename of vacation packages (filename1) prompts the user for name of the output file to write vacation packages customer preferences data and stores it as filename2 opens filename1 for reading and filename2 for writing for each of the vacation packages in filename1 it calls the genVacationPrefData method and finds the most popular month (highest value in the array) writes the data of vacation packages read from filename1 and the array returned by the genVacationPrefData method for the particular vacation package along with the most popular month for the package into filename2 Europe 41, 50, 28, 65, 90, 64, 77, 96, 6, 25, 31, 19, Popular Month: 8Caribbean 24, 45, 38, 42, 100, 56, 87, 76, 3, 55, 81, 20, Popular Month: 5Alaska 16, 53, 38, 85, 80, 24, 47, 86, 21, 39, 98, 49, Popular Month: 11Southeast Asia 88, 99, 8, 35, 60, 44, 7, 26, 29, 85, 61, 34, Popular Month: 2 returns filename2 Ouput Example file: VacationPackagePreferred.txt contains: Europe {41, 50, 28, 65, 90, 64, 77, 96, 6, 25, 31, 19} Popular Month: 8Caribbean {24, 45, 38, 42, 100, 56, 87, 76, 3, 55, 81, 20} Popular Month: 5Alaska {16, 53, 38, 85, 80, 24, 47, 86, 21, 39, 98, 49} Popular Month: 11Southeast Asia {88, 99, 8, 35, 60, 44, 7, 26, 29, 85, 61, 34} Popular Month: 2
Your exam ID is: 2YRG Write that in the “Exam ID” space on y…
Your exam ID is: 2YRG Write that in the “Exam ID” space on your sheet.
What is the output of the following code snippet? int num =…
What is the output of the following code snippet? int num = 100;if (num < 100){ if (num < 50) { num = num - 5; } else{ num = num - 10; } }else{ if (num > 150){ num = num + 5; } else{ num = num + 10; }}System.out.println(num);
Consider the following code snippet: int cnt = 0;int[][] num…
Consider the following code snippet: int cnt = 0;int numarray = new int;for (int i = 0; i < 3; i++){ for (int j = 0; j < 2; j++) { numarray = cnt; cnt++; }} What is the value of numarray after the code snippet is executed?
In the following code snippet, what is the scope of variable…
In the following code snippet, what is the scope of variable b? public static void m1(){ int i = 0; double b = 0;}public static void m2(){ double a = b + 1;}public static void main(String[] args){ m1(); m2();}
What is default?
What is default?