// The "DTfiveint" class.
import java.io.*;
public class DTfiveint
{
    public static void main (String[] args) throws IOException
    {
        BufferedReader five = new BufferedReader (new FileReader ("five.txt"));

        int multiply[] = new int [5];

        for (int i = 0 ; i < multiply.length ; i++)
        {
            multiply [i] = Integer.parseInt (five.readLine ());
        }

        int x = calc1 (multiply);
        System.out.println (x);

        int y = calc2 (multiply);
        System.out.println (y);

    } // main method


    public static int calc1 (int multiply[])
    {
        int doub = 0;

        for (int i = 0 ; i < 5 ; i++)
        {
            doub = multiply [i] * 2;
        }
        return doub;
    }


    public static int calc2 (int multiply[])
    {
        int triple = 0;

        for (int i = 0 ; i < 5 ; i++)
        {
            triple = multiply [i] * 3;


        }
        return triple;
    }
} // DTfiveint class

this does compile but it doesn't run
when i press run this pops up:
FileNotFoundException: five.txt (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileReader.<init>(Unknown Source)
at DTfiveint.main(DTfiveint.java:7)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

Recommended Answers

All 2 Replies

Error message said all The system cannot find the file specified. Check if the file exist, has the name as you call it from your program and is in same directory as your compiled java file (class). One side note, avoid using exception on main class.

it has the same name...
what do i do?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.