Question

In: Computer Science

when i run the program on eclipse it gives me this error: Exception in thread "main"...

when i run the program on eclipse it gives me this error:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
   at SIM.main(SIM.java:12)

how do I fix that ? (please fix it )

import java.util.*;
import java.util.Scanner;
import java.util.ArrayList;
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.Math;

public class SIM{
  
public static void main(String[] args) throws FileNotFoundException
{
  
   int cacheSize = Integer.parseInt( args[1] );
int assoc = Integer.parseInt( args[2] );
int replacement = Integer.parseInt( args[3] );
int WB = Integer.parseInt( args[4] );
File traces = new File(args[5]);
  
Scanner s = new Scanner(traces);

int numSets = cacheSize / (64 * assoc);
int[][] cache = new int[600][64];
int hits = 0;
int misses = 0;
int reads = 0;
int writes = 0;
int addressCount = 0;
int numSetBits = (int)(Math.log(numSets)/Math.log(2.0));

.

.

.

.

..

Solutions

Expert Solution

If you have any doubts, please give me comment...

import java.util.*;

import java.util.Scanner;

import java.util.ArrayList;

import java.io.File;

import java.io.FileNotFoundException;

import java.lang.Math;

public class SIM {

    public static void main(String[] args) throws FileNotFoundException {

        if(args.length<6){

            System.out.println("Usage: java SIM <optional-param> <cacheSize> <assoc> <replacement> <WB> <traces>");

            System.exit(0);

        }

        int cacheSize = Integer.parseInt(args[1]);

        int assoc = Integer.parseInt(args[2]);

        int replacement = Integer.parseInt(args[3]);

        int WB = Integer.parseInt(args[4]);

        File traces = new File(args[5]);

        Scanner s = new Scanner(traces);

        int numSets = cacheSize / (64 * assoc);

        int[][] cache = new int[600][64];

        int hits = 0;

        int misses = 0;

        int reads = 0;

        int writes = 0;

        int addressCount = 0;

        int numSetBits = (int) (Math.log(numSets) / Math.log(2.0));

        // your additional statements

    }

}


Related Solutions

I keep get this exception error Exception in thread "main" java.lang.NullPointerException    at Quadrilateral.returnCoordsAsString(Quadrilateral.java:44)    at...
I keep get this exception error Exception in thread "main" java.lang.NullPointerException    at Quadrilateral.returnCoordsAsString(Quadrilateral.java:44)    at Quadrilateral.toString(Quadrilateral.java:51)    at tester1.main(tester1.java:39) In this program I needed to make a Point class to create a coordinate square from x and y. I also needed to make a Quadrilateral class that has an instance reference variable to Point .The Quadrilateral class then inherits itself to other classes or in this case other shapes like square, trapazoid. I thought I did it right but...
I keep getting this error, Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for...
I keep getting this error, Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0    at simpleInheritance/simpInher.Dwelling$DriverTest.main(Dwelling.java:146) Can someone help me fix it? import java.io.BufferedReader;    import java.io.FileNotFoundException;    import java.io.FileReader;    import java.util.*;    import java.io.*;    import java.io.FileWriter;    import java.io.IOException;    class Dwelling {    /*    Declaring Variables    */    String streetAddress;    String city;    String state;    String zipCode;    int bedrooms;    double bathrooms;       /*   ...
I'm getting this error: Exception in thread "main" java.lang.NoSuchMethodError: main I tried using public static void...
I'm getting this error: Exception in thread "main" java.lang.NoSuchMethodError: main I tried using public static void main(String[] args){ but that negates all of the methods that I try to write. I'm just trying to make it so that I can enter values. Thanks. Code below: import java.util.Scanner; public class DataSet2 { private double value; private double sum; private int count; public void add(double value){    System.out.println("Enter values, enter -1 to finish");    Scanner scan = new Scanner(System.in);    value =...
Why am I getting this error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds...
Why am I getting this error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 at HW3.main(HW3.java:6) The code: import java.io.FileWriter; import java.io.IOException; public class HW3 { public static void main(String[] args) throws IOException { // 0th argument contains the name of algorithm String algo = args[0]; // 1st argument contains the name of file // Make a new file FileWriter fw = new FileWriter(args[1]); if (algo.equals("p1")) { // 2nd argument comes in the form of...
My code works in eclipse, but not in Zybooks. I keep getting this error. Exception in...
My code works in eclipse, but not in Zybooks. I keep getting this error. Exception in thread "main" java.util.NoSuchElementException at java.base/java.util.Scanner.throwFor(Scanner.java:937) at java.base/java.util.Scanner.next(Scanner.java:1478) at Main.main(Main.java:34) Your output Welcome to the food festival! Would you like to place an order? Expected output This test case should produce no output in java import java.util.Scanner; public class Main {    public static void display(String menu[])    {        for(int i=0; i<menu.length; i++)        {            System.out.println (i + " - " + menu[i]);...
can someone tell me why I'm getting the error code on Eclipse IDE: Error: Main method...
can someone tell me why I'm getting the error code on Eclipse IDE: Error: Main method is not static in class StaticInitializationBlock, please define the main method as:    public static void main(String[] args) This is what I'm working on class A { static int i; static { System.out.println(1); i = 100; } } public class StaticInitializationBlock { static { System.out.println(2); } public static void main(String[] args) { System.out.println(3); System.out.println(A.i); } }
When I run this, gdb gives me a segmentation fault at the for loop. It says...
When I run this, gdb gives me a segmentation fault at the for loop. It says I'm dereferencing curr with curr->data when curr is null. It doesn't even seem to enter the body of the loop sometimes. I am testing it on a linked list that ends with a strange element. Could you help me get this one done? Thanks so much! Here is the instruction and code: LewList *splitStrange(); This function should split the list in two, adding the...
This is in Python I am getting an error when I run this program, also I...
This is in Python I am getting an error when I run this program, also I cannot get any output. Please help! #Input Section def main(): name=input("Please enter the customer's name:") age=int(input("Enter age of the customer: ")) number_of_traffic_violations=int(input("Enter the number of traffic violations: ")) if age <=15 and age >= 105: print('Invalid Entry') if number_of_traffic_violations <0: print('Invalid Entry') #Poccessing Section def Insurance(): if age < 25 and number_of_tickets >= 4 and riskCode == 1: insurancePrice = 480 elif age >=...
I get an error when im trying to run this java program, I would appreciate if...
I get an error when im trying to run this java program, I would appreciate if someone helped me asap, I will make sure to leave a good review. thank you in advance! java class Node public class Node { private char item; private Node next; Object getNext; public Node(){    item = ' '; next = null; } public Node(char newItem) { setItem(newItem); next = null; } public Node(char newItem, Node newNext){ setItem(newItem); setNext(newNext); } public void setItem(char newItem){...
When I wrote this code in the Eclipse program, I did not see a output .....
When I wrote this code in the Eclipse program, I did not see a output .. Why? _______ public class AClass { private int u ; private int v ; public void print(){ } public void set ( int x , int y ) { } public AClass { } public AClass ( int x , int y ) { } } class BClass extends AClass { private int w ; public void print() { System.out.println (" u + v...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT