Java Reference
In-Depth Information
11. 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 tempera-
tures 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.)
Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming
marathon. Each day of the week they run certain miles and write them into
a notebook. At the end of the week, they would like to know the number
of miles run each day, the total miles for the week, and average miles run
each day. Write a program to help them analyze their data. Your program
must contain parallel arrays: An array to store the names of the runners and a
two-dimensional array of 5 rows and 7 columns to store the number of
miles run by each runner each day. Furthermore, your program must
contain at least the following methods: a method to read and store the
runners name and the number of miles run each day; a method to find the
total miles run by each runner and the average number of miles run each
day; and a method to output the results. (You may assume that the input
data is stored in a file and each line of data is in the following form:
runnerName milesDay1 milesDay2 milesDay3 milesDay4 milesDay5
milesDay6 milesDay7 .)
12.
a. Write the definition of the class Tests such that an object of this class
can store a student's first name, last name, five test scores, average tests
score, and grade. (Use an array to store the test scores.) Add constructors
and methods to manipulate data stored in an object. Among other
things, your class must contain methods to calculate test averages, return
test averages, calculate grades, return grades, and modify individual test
scores. The method toString must return test data (including student's
name, five test scores, average, and grade) as a string.
b. Write a program to calculate students' average test scores and the grade.
You may assume the following input data:
13.
Search WWH ::




Custom Search