Sale!

CSCI 1530 Assignment 6 Voice Weather Report Application (for HK) solved

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (5 votes)

Aim: 1. build a practical web information system using Java; 2. practise using String, file I/O and URL classes for web-data processing; 3. practise interpreting and extracting information from textual/ HTML information source. Task: Create a Java program for displaying and saving weather information. In this assignment, we create a practical web information application. We specifically focus on the following data source from the HK Observatory: HK Observatory Weather Forecast Text Page – Temperature in C http://www.weather.gov.hk/textonly/v2/forecast/englishwx2.htm The application requires Internet access in order to extract the weather information. It extracts and displays the raw HTML weather report on a Message Dialog. It also saves the HTML weather report to a file weather.txt with the temperature readings converted from degrees Celsius to degrees Fahrenheit. You shall use try-catch to silent all possible kinds of Exception.

At 6 p.m. at Hong Kong Observatory :
Air Temperature : 82.4 degrees Fahrenheit
Relative Humidity : 78 per cent
Weather Cartoon : No. 76 - MAINLY CLOUDY
During the past hour the mean UV Index recorded at King's Park : 0.3
Intensity of UV radiation : low
The air temperatures at other places were:
King's Park 82.4 degrees;
Wong Chuk Hang 80.6 degrees;
Ta Kwu Ling 82.4 degrees;
Lau Fau Shan 80.6 degrees;
Tai Po 80.6 degrees;
Sha Tin 80.6 degrees;
Tuen Mun 80.6 degrees;
Tseung Kwan O 80.6 degrees;
Sai Kung 80.6 degrees;
Cheung Chau 82.4 degrees;
Chek Lap Kok 82.4 degrees;
Tsing Yi 80.6 degrees;
Shek Kong 82.4 degrees;
Tsuen Wan Ho Koon 78.8 degrees;
Tsuen Wan Shing Mun Valley 80.6 degrees;
Hong Kong Park 80.6 degrees;
Shau Kei Wan 80.6 degrees;
Kowloon City 82.4 degrees;
Happy Valley 80.6 degrees;
Wong Tai Sin 84.2 degrees;
Stanley 80.6 degrees;
Kwun Tong 80.6 degrees;
Sham Shui Po 80.6 degrees;
Kai Tak Runway Park 80.6 degrees;
Yuen Long Park 82.4 degrees;
Tai Mei Tuk 80.6 degrees.

Output file weather.txt with temperature readings converted from degrees Celsius to degrees Fahrenheit.  Page 2 of 3 Tasks: 1. Create another N E W NetBeans Project Weather with a package named weather and a new Java Main Class Weather. Type your name, student ID and declaration statement clearly at the top comment block of the ALL Java source files in the project. /** * CSCI1530 Assignment 6 * Aim: build a practical weather information system using Java * * Declaration: . . . [please refer to Assignment 1 for our requirements] * Student Name: xxx [fill in yourself] * Student ID : xxx [fill in yourself] */ 2. Complete the Main Class Weather as described below: • You are suggested studying the HTML sources (using a browser such as Chrome OR writing a simple Java program to crawl the page) to view the raw text (HTML source) weather report from the HK Observatory. • Identify the specific lines containing the required data items as well as figuring out the key lines and keywords using String methods. For example, lines 37 – 77 in this sample: … Air Temperature : 28 degrees Celsius Relative Humidity : 78 per cent … The air temperatures at other places were: King’s Park 28 degrees; … Tai Mei Tuk 27 degrees. • Notice that it may NOT be starting from line 37 always. We shall look for the first line containing using String method contains. We shall also look for the end of block marker instead of hard coding at line 77. 3. On one hand, read the target lines and use a StringBuilder object to prepare a message in HTML for displaying a dialog: a. Display a dialog using JOptionPane.showMessageDialog() with HTML: String messageInHTML = “” + … + “”; // insert target lines in … JOptionPane.showMessageDialog(null, messageInHTML); 4. On the other hand, separately process each target line and output the processed lines to a file named weather.txt: • String method replaceAll may be useful for changing the word Celsius to Fahrenheit. • We shall locate the keyword “degrees” using String method indexOf which can help us extract a 2-char substring in front of it, which is a temperature reading. • Temperature in degrees Celsius shall be converted to Fahrenheit in the following way: Target lines extracted from the URL of the HKO. Page 3 of 3 String temperatureString = “29”; double tempInCelsius = Double.parseDouble(temperatureString); double tempInFahrenheit = …; // F = 9/5 C + 32 (in double!) String tempFah = “” + tempInFahrenheit; • String replace the temperature String in degrees Celsius to the Fahrenheit result. Running and Submission: 1. Run Project with Internet connection. 2. Zip and Submit the whole NetBeans project as Weather.zip. Marking Scheme and Notes: 1. The submitted program should be free of any typing mistakes, compilation errors and warnings. 2. Comment/remark, indentation, style are under assessment in every programming assignments unless specified otherwise. 3. Marker will test your programs vigorously with various inputs. You should test run your own programs properly with different user input scenarios. 4. Remember to do your submission before the due date. No late submission would be accepted. 5. If you submit multiple times, ONLY the content and time-stamp of the latest one would be counted. Be reminded to click “Submit”! We ONLY take into account the last submission. University Guideline for Plagiarism Attention is drawn to University policy and regulations on honesty in academic work, and to the disciplinary guidelines and procedures applicable to breaches of such policy and regulations. Details may be found at http://www.cuhk.edu.hk/policy/academichonesty/. With each assignment, students will be required to submit a statement that they are aware of these policies, regulations, guidelines and procedures.