Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Water Resource Usage java how to solve this question I was reviewing last year exams and I found this I tried to solve it output-file

Water Resource Usage java

how to solve this question

I was reviewing last year exams and I found this I tried to solve it

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

output-file

 ================================================================================================ || Saudi Arabia Water Resource Usage || ================================================================================================ - Number of Regions: 3 [Command] add_regions + Riyadh + Makkah + Qassim [Command] add_cities -> City: Riyadh + Ar-Riyad + Al-Kharj + Ad-Dawadmi [Command] add_cities -> City: Makkah + Makkah-al-Mukarramah + Jeddah + Taif [Command] add_cities -> City: Qassim + Buraidah + Unaizah [Command] add_population -> Region: Riyadh -> City: Ar-Riyad ------------------------------------------------------------------------ Year Population Annual Water Usage (cb.m) 2018 5,516,374 635,495,744 2019 4,503,744 638,347,384 2020 4,564,633 650,736,422 ------------------------------------------------------------------------ [Command] add_population -> Region: Riyadh -> City: Al-Kharj ------------------------------------------------------------------------ Year Population Annual Water Usage (cb.m) 2018 415,865 43,593,433 2019 418,636 42,957,485 2020 425,330 44,326,383 ------------------------------------------------------------------------ [Command] add_population -> Region: Riyadh -> City: Ad-Dawadmi ------------------------------------------------------------------------ Year Population Annual Water Usage (cb.m) 2018 263,847 28,453,343 2019 269,038 29,504,583 2020 271,947 30,129,347 ------------------------------------------------------------------------ [Command] add_population -> Region: Makkah -> City: Makkah-al-Mukarramah ------------------------------------------------------------------------ Year Population Annual Water Usage (cb.m) 2018 2,119,393 533,563,432 2019 2,124,848 545,564,533 2020 2,042,047 535,765,756 ------------------------------------------------------------------------ [Command] add_population -> Region: Makkah -> City: Jeddah ------------------------------------------------------------------------ Year Population Annual Water Usage (cb.m) 2018 3,516,374 345,675,764 2019 3,503,744 356,006,874 2020 3,564,633 335,834,763 ------------------------------------------------------------------------ [Command] add_population -> Region: Makkah -> City: Taif ------------------------------------------------------------------------ Year Population Annual Water Usage (cb.m) 2018 527,834 21,565,633 2019 525,437 22,300,454 2020 543,823 22,506,565 ------------------------------------------------------------------------ [Command] add_population -> Region: Qassim -> City: Buraidah ------------------------------------------------------------------------ Year Population Annual Water Usage (cb.m) 2020 419,383 23,594,575 ------------------------------------------------------------------------ [Command] add_population -> Region: Qassim -> City: Unaizah ------------------------------------------------------------------------ Year Population Annual Water Usage (cb.m) 2020 119,383 3,989,786 ------------------------------------------------------------------------ [Command] print_result -> Region: Riyadh -> City: Ar-Riyad --------------------------------------------------------------------------------------------------------------- Year Population Annual Water Usage (cb.m) Per capita daily usage (l) Change --------------------------------------------------------------------------------------------------------------- 2018 5,516,374 635,495,744 315 NA 2019 4,503,744 638,347,384 388 23.17% 2020 4,564,633 650,736,422 390 0.52% --------------------------------------------------------------------------------------------------------------- [Command] print_result -> Region: Riyadh -> City: Al-Kharj --------------------------------------------------------------------------------------------------------------- Year Population Annual Water Usage (cb.m) Per capita daily usage (l) Change --------------------------------------------------------------------------------------------------------------- 2018 415,865 43,593,433 287 NA 2019 418,636 42,957,485 281 -2.09% 2020 425,330 44,326,383 285 1.42% --------------------------------------------------------------------------------------------------------------- [Command] print_result -> Region: Riyadh -> City: Ad-Dawadmi --------------------------------------------------------------------------------------------------------------- Year Population Annual Water Usage (cb.m) Per capita daily usage (l) Change --------------------------------------------------------------------------------------------------------------- 2018 263,847 28,453,343 295 NA 2019 269,038 29,504,583 300 1.69% 2020 271,947 30,129,347 303 1.00% --------------------------------------------------------------------------------------------------------------- [Command] print_result -> Region: Makkah -> City: Makkah-al-Mukarramah --------------------------------------------------------------------------------------------------------------- Year Population Annual Water Usage (cb.m) Per capita daily usage (l) Change --------------------------------------------------------------------------------------------------------------- 2018 2,119,393 533,563,432 689 NA 2019 2,124,848 545,564,533 703 2.03% 2020 2,042,047 535,765,756 718 2.13% --------------------------------------------------------------------------------------------------------------- [Command] print_result -> Region: Makkah -> City: Jeddah --------------------------------------------------------------------------------------------------------------- Year Population Annual Water Usage (cb.m) Per capita daily usage (l) Change --------------------------------------------------------------------------------------------------------------- 2018 3,516,374 345,675,764 269 NA 2019 3,503,744 356,006,874 278 3.35% 2020 3,564,633 335,834,763 258 -7.19% --------------------------------------------------------------------------------------------------------------- [Command] print_result -> Region: Makkah -> City: Taif --------------------------------------------------------------------------------------------------------------- Year Population Annual Water Usage (cb.m) Per capita daily usage (l) Change --------------------------------------------------------------------------------------------------------------- 2018 527,834 21,565,633 111 NA 2019 525,437 22,300,454 116 4.50% 2020 543,823 22,506,565 113 -2.59% --------------------------------------------------------------------------------------------------------------- [Command] print_result -> Region: Qassim -> City: Buraidah --------------------------------------------------------------------------------------------------------------- Year Population Annual Water Usage (cb.m) Per capita daily usage (l) Change --------------------------------------------------------------------------------------------------------------- 2020 419,383 23,594,575 154 NA --------------------------------------------------------------------------------------------------------------- [Command] print_result -> Region: Qassim -> City: Unaizah --------------------------------------------------------------------------------------------------------------- Year Population Annual Water Usage (cb.m) Per capita daily usage (l) Change --------------------------------------------------------------------------------------------------------------- 2020 119,383 3,989,786 91 NA --------------------------------------------------------------------------------------------------------------- [Command] find_lowest_usage * The city with lowest per capita water usage in all regions ------------------------------------------------------------------------------------------ Year Population Annual Water Usage (cb.m) Per capita daily usage (l) ------------------------------------------------------------------------------------------ 2020 119,383 3,989,786 91 ------------------------------------------------------------------------------------------ In Region: Qassim, City: Unaizah [Command] find_higest_usage * The city with highest per capita water usage in all regions ------------------------------------------------------------------------------------------ Year Population Annual Water Usage (cb.m) Per capita daily usage (l) ------------------------------------------------------------------------------------------ 2020 2,042,047 535,765,756 718 ------------------------------------------------------------------------------------------ In Region: Makkah, City: Makkah-al-Mukarramah [Command] about_developer -> Developed By: [Write your Full Name] -> University ID: [Write your University ID] -> Section: [Write your CPCS 203 Section] Thank You! :)
Description According to reports, the water usage rate of Saudi Arabia is twice the world average. To deal with this alarming situation, the Department of Statistics has collected the total water usage data from various cities in different regions for the recent years along with the population details during these years. You are required to develop an application that can use this data as input and provide insight details of the water usage from different perspective such as the per year percentage increase or decrease in water usage over time in a specific city, the per capita water usage, the lowest and highest water usage cities etc. All this information will be helpful to help in reducing the water usage per capita. Table 1 shows the data of regions, cities, population and the annual total water usage in cubic meter (cb.m). Region Riyadh City Ar-Riyad Al-Kharj Year 2018 2019 2020 2018 2019 2020 2018 2019 2020 2018 Ad-Dawadmi Makkah Makkah-al- Mukarramah Population 5516374 4503744 4564633 415865 418636 425330 263847 269038 271947 2119393 2124848 2042047 3516374 3503744 3564633 527834 525437 543823 419383 119383 Water Usage cb.m 635495744 638347384 650736422 43593433 42957485 44326383 28453343 29504583 30129347 533563432 545564533 535765756 345675764 356006874 3358 34763 21565633 22300454 22506565 23594575 9557786 Jeddah 2019 2020 2018 2019 2020 2018 2019 2020 2020 2020 Taif Qassim Buraidah Unaizah able 1 Water Usage Data From the given Table 1, you need to make different arrays to store all the data used in the program. For example, you need a one-dimension array to store region. Each region contains one or more cities, so you need a two-dimension array to store the city. Similarly, each city has records of several previous years. The program stores the year, population, and water usage in different column. Therefore, you need 3 three-dimension arrays: (first one to store the year, second one to store the population, and third one to store the water usage). Basic Requirements The program must read the data from a text file called "input.txt" that follows a specific pattern. If the file doesn't exist, print a message to let the user know what happened. - see Input File Pattern section for more details. The program must generate a text file as the output called "output.txt" that contains the results of the commands written in the input file - see Output File Pattern section for more details. The program must load and deal with data dynamically. This means you should never write the data as hard codes. You should use loops to deal with the arrays. The program must follow the format of the output file as possible. Input File Pattern The input file called 'input.txt' is attached with this document. The pattern, which the input file follows, is explained in the following input file example: 3 //The first line in the input file: the number of the region stored in this file. In other words, the size of region array. 3 3 2 //The second line in the input file: the number of cities in each region. It is separated with a space. Ex: the first region has 3 cities, the second region has 3 cities, and the third region type has 2 cities. In other words, cities[0] = new String[3]; cities[1] = new String[3]; cities[2] = new String[2]; add_regions Riyadh Makkah Qassim//The add_regions command registers the names of the region. It takes a list of the region names separated by a space. Ex: regions[0] = "Riyadh"; regions[1] = "Makkah"; regions[2] = "Qassim"; add_cities Riyadh Ar-Riyad Al-Kharj Ad-Dawadmi //The add_cities command is used to registers the names of the cities. It takes the name of the region as the first argument, and then the list of the city names separated by a space. "Riyadh" region has three cities, so three names are defined (Ar-Riyad, Al- Kharj, Ad-Dawadmi). Note: you have to find the index of the region and the index of the city to set the names. add_cities Makkah Makkah-al-Mukarramah Jeddah Taif // "Makkah" region has three cities, so three names are defined in the command (Makkah-al- Mukarramah, Jeddah, Taif). add_cities Qassim Buraidah Unaizah // "Qassim region has two cities, so two names are defined in the command (Buraidah, Unaizah). add_populations Riyadh Ar-Riyad 3 //"add_populations" command registers the population details of the city for a region. It takes the name of the region as the first argument, the name of the city as the second argument, the number of the years as the third argument. All these arguments are separated by a space. This command is the followed by list of details including year, population, and Water usage - all separated by a space. Ex: For "Riyadh" region and "Ar-Riyad" city, there are 3 records containing the year, population and water usage. As mentioned earlier, you need 3 three- dimension arrays; the first one to store the year as a string, the second one to store the population as an int, and the third one to store water usage as long. 2018 5516374 635495744 2019 4503744 638347384 2020 4564633 650736422 add_populations Riyadh Al-Kharj 3 //In the "Riyadh region and "Al- Kharj" city, 3 years of record is available, and the information is listed below. 2018 415865 43593433 2019 418636 42957485 2020 425330 44326383 add_populations Riyadh Ad-Dawadmi 3 //In the "Riyadh" region and "Ad- Dawadmi" city, 3 years of record is available, and the information is listed below. 2018 263847 28453343 2019 269038 29504583 2020 271947 30129347 add_populations Makkah Makkah-al-Mukarramah 3 //In the "Makkah" region and "Makkah-al-Mukarramah" city, 3 years of record is available, and the information is listed below. 2018 2119393 533563432 2019 2124848 545564533 2020 2042047 535765756 add_populations Makkah Jeddah 3 //In the "Makkah" region and "Jeddah" city, 3 years of record is available, and the information is listed below. 2018 3516374 345675764 2019 3503744 356006874 2020 3564633 335834763 add_populations Makkah Taif 3 //In the "Makkah" region and "Taif" city, 3 years of record is available, and the information is listed below. 2018 527834 21565633 2019 525437 22300454 2020 543823 22506565 add_populations Qassim Buraidah 1 //In the "Qassim" region and "Buraidah" city, only 1 year of record is available, and the information is listed below. 2020 419383 23594575 add_populations Qassim Unaizah 1 //In the "Qassim region and "Unaizah" city, only 1 year of record is available, and the information is listed below. 2020 119383 3989786 print_result Riyadh Ar-Riyad //"print_result" is a command that prints details about the per capita water usage and the change in percentage with respect to the previous year. It takes the name of the region as the first argument, the name of the city as the second argument. All these arguments are separated with a space. Ex: prints the details of the city "Ar-Riyad" in the "Riyadh" region. Hints: Percentage change of per capita = [(This Year - Last Year) / Last Year] x 100 Do not calculate percentage change for the first year of available record and simply print "NA" (for Not Applicable) Per capita daily usage (liters) = Total water usage in liters/ (total population x 365) 1 cb.m = 1000 liters print_result Riyadh Al-Kharj //Prints the details of the "Al-Khari" city in the "Riyadh" region. print_result Riyadh Ad-Dawadmi //Prints the details of the "Al-Dawadmi" city in the "Riyadh" region. print_result Makkah Makkah-al-Mukarramah //Prints the details of the "Makkah-al-Mukarramah" city in the "Makkah region. print_result Makkah Jeddah //Prints the details of the "Jeddah" city in the "Makkah" region. print_result Makkah Taif //Prints the details of the "Taif" city in the "Makkah" region. print_result Qassim Buraidah //Prints the details of the "Buraidah" city in the "Qassim" region. print_result Qassim Unaizah //Prints the details of the "Unaizah" city in the "Qassim" region. find_lowest_usage // "find_lowest_usage" is a command that finds and prints the record of lowest per capita water usage. find_highest_usage // "find_highest_usage" is a command that finds and prints the record of highest per capita water usage. about_developer // "about_developer" is a command that prints the information about the programmer who created this program (Your information). exit //" exit" is a command that ends the program. After this command, the output file called "output.txt" must be generated in the same directory of the program. Also, the date and time of the generation should be printed in the output file. 1 3 2 3 3 2 2 3 add_regions Riyadh Makkah Qassim add_cities Riyadh Ar-Riyad Al-Kharj Ad-Dawadmi 5 add_cities Makkah Makkah-al-Mukarramah Jeddah Taif 6 add_cities Qassim Buraidah Unaizah 7 add_populations Riyadh Ar-Riyad 3 8 2018 5516374 635495744 9 2019 4503744 638347384 10 2020 4564633 650736422 11 add_populations Riyadh Al-Kharj 3 12 2018 415865 43593433 * 2 13 2019 418636 42957485 14 2020 425330 44326383 15 add_populations Riyadh Ad-Dawadmi 3 16 2018 263847 28453343 17 2019 269038 29504583 18 2020 271947 30129347 19 add_populations Makkah Makkah-al-Mukarramah 3 20 2018 2119393 533563432 21 2019 2124848 545564533 22. 2000 2001 ZCZEC 2020 2042047 535765756 23 add_populations Makkah Jeddah 3 24 2018 3516374 345675764 *** 25 2019 3503744 356006874 26 2020 3564633 335834763 27 add_populations Makkah Taif 3 wa 28 2018 527834 21565633 29 2019 525437 22300454 30 2020 543823 22506565 add populations Qassim Buraidah 1 - X 32 2020 419383 23594575 33 add populations Qassim Unaizah 1 34 2020 119383 3989786 35 print_result Riyadh Ar-Riyad 36 print_result Riyadh Al-Kharj 37 print_result Riyadh Ad-Dawadmi 38 print_result Makkah Makkah-al-Mukarramah print result Makkah Jeddah 40 print_result Makkah Taif print_result Qassim Buraidah print_result Qassim Unaizah 43 find_lowest_usage 44 find_higest_usage 45 about_developer 46 exit Figure 1. Input file (input.txt) 31 39 41 42 Output File Pattern The output file should include all the results of the commands that have been read from the input file "input.txt". The format of the output file is provided as separate file "output.txt". Commands You Have to Implement As you see in the input and output files, there are some commands that you have to implement: Command Description Command #1 add_regions It registers the names of the region. It takes a list of the region names separated by a space. add_regions Riyadh Makkah Qassim [Command) add_regions + Riyadh + Makkah + Qassim Example Output of the Example Command Description Command #2 add_cities It registers the names of the cities. It takes the name of the region as the first argument, and then the list of the cities separated by a space. add_cities Riyadh Ar-Riyad Al-Kharj Ad-Dawadmi [Command) add_cities -> City: Riyadh + Ar-Riyad Al-Khari + Ad-Dawadmi Example Output of the Example Command Description Command #3 add populations It registers the year, population, and water usage details of the city. It takes the name of the region as the first argument, the name of the city as the second argument, the number of year as the third argument. All these arguments are separated with a space. Then it lists the year, population and water usage separated with a space. add_populations Riyadh Ar-Riyad 3 2018 5516374 635495744 2019 4563744 638347384 2020 45 64633 650736422 Example Output of the Example [Commandl add_population - Region: Riyadh -> City: Ar-Riyad Year 2018 2019 2020 Population 5,516,374 4,563, 744 1,564,633 Annual Water Usage (cb.m) 635,495,744 638,347,384 650,736,422 Command Description Command #4 print_result It prints details about the year, population, annual water usage, per capita daily usage and change (in percentage of the specific city in a region. It takes the name of the region as the first argument, the name of the city as the second argument. All these arguments are separated with a space. print_result Riyadh Ar-Riyad Example Output of the Example Ccnitandl print_result -> Reglur: Riyadh -> City: Ar-Riyad Year Annual Water Usage feb.n) Per capita daily wage (L) Change 2018 2019 2A 2A Population 5,536,374 4,503, 744 4.574,633 5.35, 195, 744 638,347,384 650,735,472 315 388 390 NA 23.178 2.5 Command Description Example Output of the Example Command #5 find lowest_usage It is a command that finds and prints the lowest water usage per capita record. find_lowest_mileage Commandl find lowest_usage The city with lowest per canita water sacr in all regions Year Population Annual Water Usage (ob. n) Per cap-ta daily usage (L) ----- 2020 119,383 3,989, 780 91 In Region: Cassin, City: Unaizah Command Description Example Output of the Example Command #6 find_highest_usage It is a command that finds and prints the highest water usage per capita record. find_highest mileage [Commandl find_higest_usage * The city with highest per capita water usage in all regions Year Population Annual Water Usage (c3.a) Per capita daily usage (1) 202 2,047,947 545,165,756 318 In Region: Makkah, City: Makkah-al-Mukarramah Command Description Example Output of the Example Command #7 about_developer It prints the information about the developer of the guide (student info). about_developer Command: about_developer -> Developed By: Ali Alqahtai -> University ID: 2004832 -> Section: DA Command Description Command #8 exit It ends the program. After this command, the output file called "output.txt" must be generated in the same directory of the program. Also, the date and time of the generation should be printed in the output file. exit Thank You! :) Report generated on Sun Feb 07 17:18:32 AST 2021 Example Output of the Example Deliverable You have to subinit only the java file of your code. The file and the class names should be "Project_1_Your FirstName_YourLastName_YourID". Where "YourFirstName" is your first name, "YourLastName is your last name, "YourID" is vour type ID. Output Format Your program must generate output in a similar format to the given sample output file [output.txt]. Good Luck and Start Early! Description According to reports, the water usage rate of Saudi Arabia is twice the world average. To deal with this alarming situation, the Department of Statistics has collected the total water usage data from various cities in different regions for the recent years along with the population details during these years. You are required to develop an application that can use this data as input and provide insight details of the water usage from different perspective such as the per year percentage increase or decrease in water usage over time in a specific city, the per capita water usage, the lowest and highest water usage cities etc. All this information will be helpful to help in reducing the water usage per capita. Table 1 shows the data of regions, cities, population and the annual total water usage in cubic meter (cb.m). Region Riyadh City Ar-Riyad Al-Kharj Year 2018 2019 2020 2018 2019 2020 2018 2019 2020 2018 Ad-Dawadmi Makkah Makkah-al- Mukarramah Population 5516374 4503744 4564633 415865 418636 425330 263847 269038 271947 2119393 2124848 2042047 3516374 3503744 3564633 527834 525437 543823 419383 119383 Water Usage cb.m 635495744 638347384 650736422 43593433 42957485 44326383 28453343 29504583 30129347 533563432 545564533 535765756 345675764 356006874 3358 34763 21565633 22300454 22506565 23594575 9557786 Jeddah 2019 2020 2018 2019 2020 2018 2019 2020 2020 2020 Taif Qassim Buraidah Unaizah able 1 Water Usage Data From the given Table 1, you need to make different arrays to store all the data used in the program. For example, you need a one-dimension array to store region. Each region contains one or more cities, so you need a two-dimension array to store the city. Similarly, each city has records of several previous years. The program stores the year, population, and water usage in different column. Therefore, you need 3 three-dimension arrays: (first one to store the year, second one to store the population, and third one to store the water usage). Basic Requirements The program must read the data from a text file called "input.txt" that follows a specific pattern. If the file doesn't exist, print a message to let the user know what happened. - see Input File Pattern section for more details. The program must generate a text file as the output called "output.txt" that contains the results of the commands written in the input file - see Output File Pattern section for more details. The program must load and deal with data dynamically. This means you should never write the data as hard codes. You should use loops to deal with the arrays. The program must follow the format of the output file as possible. Input File Pattern The input file called 'input.txt' is attached with this document. The pattern, which the input file follows, is explained in the following input file example: 3 //The first line in the input file: the number of the region stored in this file. In other words, the size of region array. 3 3 2 //The second line in the input file: the number of cities in each region. It is separated with a space. Ex: the first region has 3 cities, the second region has 3 cities, and the third region type has 2 cities. In other words, cities[0] = new String[3]; cities[1] = new String[3]; cities[2] = new String[2]; add_regions Riyadh Makkah Qassim//The add_regions command registers the names of the region. It takes a list of the region names separated by a space. Ex: regions[0] = "Riyadh"; regions[1] = "Makkah"; regions[2] = "Qassim"; add_cities Riyadh Ar-Riyad Al-Kharj Ad-Dawadmi //The add_cities command is used to registers the names of the cities. It takes the name of the region as the first argument, and then the list of the city names separated by a space. "Riyadh" region has three cities, so three names are defined (Ar-Riyad, Al- Kharj, Ad-Dawadmi). Note: you have to find the index of the region and the index of the city to set the names. add_cities Makkah Makkah-al-Mukarramah Jeddah Taif // "Makkah" region has three cities, so three names are defined in the command (Makkah-al- Mukarramah, Jeddah, Taif). add_cities Qassim Buraidah Unaizah // "Qassim region has two cities, so two names are defined in the command (Buraidah, Unaizah). add_populations Riyadh Ar-Riyad 3 //"add_populations" command registers the population details of the city for a region. It takes the name of the region as the first argument, the name of the city as the second argument, the number of the years as the third argument. All these arguments are separated by a space. This command is the followed by list of details including year, population, and Water usage - all separated by a space. Ex: For "Riyadh" region and "Ar-Riyad" city, there are 3 records containing the year, population and water usage. As mentioned earlier, you need 3 three- dimension arrays; the first one to store the year as a string, the second one to store the population as an int, and the third one to store water usage as long. 2018 5516374 635495744 2019 4503744 638347384 2020 4564633 650736422 add_populations Riyadh Al-Kharj 3 //In the "Riyadh region and "Al- Kharj" city, 3 years of record is available, and the information is listed below. 2018 415865 43593433 2019 418636 42957485 2020 425330 44326383 add_populations Riyadh Ad-Dawadmi 3 //In the "Riyadh" region and "Ad- Dawadmi" city, 3 years of record is available, and the information is listed below. 2018 263847 28453343 2019 269038 29504583 2020 271947 30129347 add_populations Makkah Makkah-al-Mukarramah 3 //In the "Makkah" region and "Makkah-al-Mukarramah" city, 3 years of record is available, and the information is listed below. 2018 2119393 533563432 2019 2124848 545564533 2020 2042047 535765756 add_populations Makkah Jeddah 3 //In the "Makkah" region and "Jeddah" city, 3 years of record is available, and the information is listed below. 2018 3516374 345675764 2019 3503744 356006874 2020 3564633 335834763 add_populations Makkah Taif 3 //In the "Makkah" region and "Taif" city, 3 years of record is available, and the information is listed below. 2018 527834 21565633 2019 525437 22300454 2020 543823 22506565 add_populations Qassim Buraidah 1 //In the "Qassim" region and "Buraidah" city, only 1 year of record is available, and the information is listed below. 2020 419383 23594575 add_populations Qassim Unaizah 1 //In the "Qassim region and "Unaizah" city, only 1 year of record is available, and the information is listed below. 2020 119383 3989786 print_result Riyadh Ar-Riyad //"print_result" is a command that prints details about the per capita water usage and the change in percentage with respect to the previous year. It takes the name of the region as the first argument, the name of the city as the second argument. All these arguments are separated with a space. Ex: prints the details of the city "Ar-Riyad" in the "Riyadh" region. Hints: Percentage change of per capita = [(This Year - Last Year) / Last Year] x 100 Do not calculate percentage change for the first year of available record and simply print "NA" (for Not Applicable) Per capita daily usage (liters) = Total water usage in liters/ (total population x 365) 1 cb.m = 1000 liters print_result Riyadh Al-Kharj //Prints the details of the "Al-Khari" city in the "Riyadh" region. print_result Riyadh Ad-Dawadmi //Prints the details of the "Al-Dawadmi" city in the "Riyadh" region. print_result Makkah Makkah-al-Mukarramah //Prints the details of the "Makkah-al-Mukarramah" city in the "Makkah region. print_result Makkah Jeddah //Prints the details of the "Jeddah" city in the "Makkah" region. print_result Makkah Taif //Prints the details of the "Taif" city in the "Makkah" region. print_result Qassim Buraidah //Prints the details of the "Buraidah" city in the "Qassim" region. print_result Qassim Unaizah //Prints the details of the "Unaizah" city in the "Qassim" region. find_lowest_usage // "find_lowest_usage" is a command that finds and prints the record of lowest per capita water usage. find_highest_usage // "find_highest_usage" is a command that finds and prints the record of highest per capita water usage. about_developer // "about_developer" is a command that prints the information about the programmer who created this program (Your information). exit //" exit" is a command that ends the program. After this command, the output file called "output.txt" must be generated in the same directory of the program. Also, the date and time of the generation should be printed in the output file. 1 3 2 3 3 2 2 3 add_regions Riyadh Makkah Qassim add_cities Riyadh Ar-Riyad Al-Kharj Ad-Dawadmi 5 add_cities Makkah Makkah-al-Mukarramah Jeddah Taif 6 add_cities Qassim Buraidah Unaizah 7 add_populations Riyadh Ar-Riyad 3 8 2018 5516374 635495744 9 2019 4503744 638347384 10 2020 4564633 650736422 11 add_populations Riyadh Al-Kharj 3 12 2018 415865 43593433 * 2 13 2019 418636 42957485 14 2020 425330 44326383 15 add_populations Riyadh Ad-Dawadmi 3 16 2018 263847 28453343 17 2019 269038 29504583 18 2020 271947 30129347 19 add_populations Makkah Makkah-al-Mukarramah 3 20 2018 2119393 533563432 21 2019 2124848 545564533 22. 2000 2001 ZCZEC 2020 2042047 535765756 23 add_populations Makkah Jeddah 3 24 2018 3516374 345675764 *** 25 2019 3503744 356006874 26 2020 3564633 335834763 27 add_populations Makkah Taif 3 wa 28 2018 527834 21565633 29 2019 525437 22300454 30 2020 543823 22506565 add populations Qassim Buraidah 1 - X 32 2020 419383 23594575 33 add populations Qassim Unaizah 1 34 2020 119383 3989786 35 print_result Riyadh Ar-Riyad 36 print_result Riyadh Al-Kharj 37 print_result Riyadh Ad-Dawadmi 38 print_result Makkah Makkah-al-Mukarramah print result Makkah Jeddah 40 print_result Makkah Taif print_result Qassim Buraidah print_result Qassim Unaizah 43 find_lowest_usage 44 find_higest_usage 45 about_developer 46 exit Figure 1. Input file (input.txt) 31 39 41 42 Output File Pattern The output file should include all the results of the commands that have been read from the input file "input.txt". The format of the output file is provided as separate file "output.txt". Commands You Have to Implement As you see in the input and output files, there are some commands that you have to implement: Command Description Command #1 add_regions It registers the names of the region. It takes a list of the region names separated by a space. add_regions Riyadh Makkah Qassim [Command) add_regions + Riyadh + Makkah + Qassim Example Output of the Example Command Description Command #2 add_cities It registers the names of the cities. It takes the name of the region as the first argument, and then the list of the cities separated by a space. add_cities Riyadh Ar-Riyad Al-Kharj Ad-Dawadmi [Command) add_cities -> City: Riyadh + Ar-Riyad Al-Khari + Ad-Dawadmi Example Output of the Example Command Description Command #3 add populations It registers the year, population, and water usage details of the city. It takes the name of the region as the first argument, the name of the city as the second argument, the number of year as the third argument. All these arguments are separated with a space. Then it lists the year, population and water usage separated with a space. add_populations Riyadh Ar-Riyad 3 2018 5516374 635495744 2019 4563744 638347384 2020 45 64633 650736422 Example Output of the Example [Commandl add_population - Region: Riyadh -> City: Ar-Riyad Year 2018 2019 2020 Population 5,516,374 4,563, 744 1,564,633 Annual Water Usage (cb.m) 635,495,744 638,347,384 650,736,422 Command Description Command #4 print_result It prints details about the year, population, annual water usage, per capita daily usage and change (in percentage of the specific city in a region. It takes the name of the region as the first argument, the name of the city as the second argument. All these arguments are separated with a space. print_result Riyadh Ar-Riyad Example Output of the Example Ccnitandl print_result -> Reglur: Riyadh -> City: Ar-Riyad Year Annual Water Usage feb.n) Per capita daily wage (L) Change 2018 2019 2A 2A Population 5,536,374 4,503, 744 4.574,633 5.35, 195, 744 638,347,384 650,735,472 315 388 390 NA 23.178 2.5 Command Description Example Output of the Example Command #5 find lowest_usage It is a command that finds and prints the lowest water usage per capita record. find_lowest_mileage Commandl find lowest_usage The city with lowest per canita water sacr in all regions Year Population Annual Water Usage (ob. n) Per cap-ta daily usage (L) ----- 2020 119,383 3,989, 780 91 In Region: Cassin, City: Unaizah Command Description Example Output of the Example Command #6 find_highest_usage It is a command that finds and prints the highest water usage per capita record. find_highest mileage [Commandl find_higest_usage * The city with highest per capita water usage in all regions Year Population Annual Water Usage (c3.a) Per capita daily usage (1) 202 2,047,947 545,165,756 318 In Region: Makkah, City: Makkah-al-Mukarramah Command Description Example Output of the Example Command #7 about_developer It prints the information about the developer of the guide (student info). about_developer Command: about_developer -> Developed By: Ali Alqahtai -> University ID: 2004832 -> Section: DA Command Description Command #8 exit It ends the program. After this command, the output file called "output.txt" must be generated in the same directory of the program. Also, the date and time of the generation should be printed in the output file. exit Thank You! :) Report generated on Sun Feb 07 17:18:32 AST 2021 Example Output of the Example Deliverable You have to subinit only the java file of your code. The file and the class names should be "Project_1_Your FirstName_YourLastName_YourID". Where "YourFirstName" is your first name, "YourLastName is your last name, "YourID" is vour type ID. Output Format Your program must generate output in a similar format to the given sample output file [output.txt]. Good Luck and Start Early

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

Were they made on a timely basis?

Answered: 1 week ago

Question

Explain consumer behaviour.

Answered: 1 week ago

Question

Explain the factors influencing consumer behaviour.

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago