Acitivity 5 CC203

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

West Visayas State University

COLLEGE OF INFORMATION AND COMMUNICATIONS TECHNOLOGY


Luna St., La Paz, Iloilo City 5000
Iloilo, Philippines
* Trunkline: (063) (033) 320-0870 loc. 1403 * Telefax No.: (033) 320-0879 Acc. No.: M2700903PM
* Website: www.wvsu.edu.ph * Email Address: cict@wvsu.edu.ph
PHI-18939-2-QM

Activity 5
Instructions:
The filename of this activity is Activity5 – (Complete name). Then save this activity on the
Google Drive. Place your code at the end of these problem.

Problem 1:
Write a program that uses a two-dimensional array to store the highest and lowest
temperatures for each month of the year. The program should output the average high,
average low, and highest and lowest temperatures of the year. Your program must consist
of the following methods
a. Method getData: This method reads and stores the data in the two-dimensional array.
b. Method averageHigh: This method calculates and returns the average high temperature
of the year.
c. Method averageLow: This method calculates and returns the average low temperature of
the year.
d. Method indexHighTemp: This method returns the index of the highest temperature in the
array.
e. Method indexLowTemp: This method returns the index of the lowest temperature in the
array.
(These methods must all have the appropriate parameters.)

Problem 2:
Guessing the Number game program. If the guessed number is not correct, the program
outputs a message indicating whether the guess is low or high. If diff is 0, then guess is
correct and the program outputs a message indicating that the user guessed the correct
number. Suppose diff is not 0. Then, the program outputs the message as follows:

a. If diff is greater than or equal to 50, the program outputs the message indicating that the
guess is very high (if guess is greater than num) or very low (if guess is less than num).
b. If diff is greater than or equal to 30 and less than 50, the program outputs the message
indicating that the guess is high (if guess is greater than num) or low (if guess is less than
num).
c. If diff is greater than or equal to 15 and less than 30, the program outputs the message
indicating that the guess is moderately high (if guess is greater than num) or moderately low
(if guess is less than num).
d. If diff is greater than 0 and less than 15, the program outputs the message indicating that
the guess is somewhat high (if guess is greater than num) or somewhat low (if guess is less
than num).

You might also like