Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

TestFile contains 7 day weather forecast. Write a complete java program to read the temperatures from the file, (10 marks) make sure to handle the

  • TestFile contains 7 day weather forecast.
  • Write a complete java program to read the temperatures from the file, (10 marks) make sure to handle the error if the file was not found. (4 marks)
  • Store the temperatures in a 1 Dimensional array (4 marks)
  • Find the highest and lowest temperatures of the week, and print them (12 marks) I made the TestFile.txt but I got a error: java.io.FileNotFoundException: TestFile.txt (The system cannot find the file specified) : Error File not found. I have the code:

    import java.util.*; import java.io.*; public class Test{

    public static void main(String[] args) {

    try{ File tf = new File("TestFile.txt"); Scanner scn = new Scanner(tf); Double [] tempArr = new Double[7]; int index=0;

    while(scn.hasNextLine()){ tempArr[index] = scn.nextDouble(); index++; }

    Double highestTemp = tempArr[0], lowestTemp = tempArr[0]; for(int i =0;i tempArr[i]){ lowestTemp = tempArr[i]; } } System.out.println("Highest temperature = "+highestTemp); System.out.println("Lowest temperature = "+lowestTemp); }

    catch(FileNotFoundException exc){ System.out.println(exc + " : Error File not found"); } } } image text in transcribed

eclipse-workspace - Azhar/src/TestFile txt - Eclipse IDE Eile Edit Navigate Search Project Run Window Help Quick Access TestFile.txt Testjava 1 34.77 229.22 3 31.55 432.10 526.66 621.47 /20.011 Package Explorer > Accidents Assigments Azhar JRC System Library JavaSC-1.8] SIC # (default package) > Os.java > Test.java TestFile txt > Barklards > Employee3 > Final >Hamadi > M251 > BM251TMA > M251TMAA >rov > Prev2 rev2 >rev TM105 > JRE System Library JavaSE 1.8) src (default package) > average.java > average2java ClassAverage2.java > DrawStars.java > Ellipse.java > factorialjava > Factorial orloop.java > FindTheSumnjava > FindTheSum With PublicstaticSumjava > Forloop Trainingjava TorLoop Training2java > Gradeforl.cap.java > Gradesjava > GradesFor students java > D Increment Method.java Writable Insert 7:6:47 Type here to search o ws ENG 2:13 PM UK 12/29/2020

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

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

Students also viewed these Databases questions

Question

Find vC(t) for t > 0 in the circuit in Fig. P6.65. t=0 iL 1 1H 1A

Answered: 1 week ago

Question

Why and how might education have externality effect.

Answered: 1 week ago

Question

1. Explain how business strategy affects HR strategy.

Answered: 1 week ago