Question: Write a Java program that contains a method named DisplayTemperature. The argument to this method is the number of days and the temperature on the
Write a Java program that contains a method named DisplayTemperature. The argument to this method is the number of days and the temperature on the first day. The method is used to decrease the temperature by two degree every day in the first half of a given period and increase by one degree in the second half. If the number of days in a specified period is odd, the first half will be considered a day less than the second half. The method then displays a table showing the days and the temperatures on those days (as shown below).
The main method in the program will first ask the users to enter the number of days in the specified period and the temperature on the first day (as shown below). The program should then call the DisplayTemperature method that outputs the table (as shown below).
For example, if a user enters as follows:
Number of days in the period: 11
Temperature on the first day: -10
The method should display the following:
day temperature
1 -10
2 -12
3 -14
4 -16
5 -18
6 -17
7 -16
8 -15
9 -14
10 -13
11 -12
2. Write a Java program that contains a method named ReadAndFindMax. The argument to this method is the filename (of String type). The method opens the file specified in the method argument filename and then reads integers from it. This file can contain any number of integers. Next, the method finds the maximum of these integers and returns it.
The main method must first ask the user to enter the filename; then call ReadAndFindMax method with the entered filename as an argument; and finally it must print the maximum integer value that is returned from this method.
You would have the screenshots similar to shown below (assuming that you are using console I/O):
Enter the file name: myfile.txt
The maximum number is 45
Assuming that the file myfile.txt contains the following four integer numbers:
23
34
45
2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
