0
// 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)

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by 9107you
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.