Ok, so the program we are supposed to do is to create implement a employee class then create a main tester class that can accept user inputs for 5 employee names, salaries, and performance rating. After that, we have to input code to calculate a provided raise amount, then print out the array with the updated raises. I have completed the program with no syntax errors, but it doesn't do anything. not even a screen comes up on my end to accept user inputs. I know its something basic, but what am i missing
Employee class
public class Employee
{
private String employeeName;
private int salary;
private int performanceRating;
I'm trying to have the program create a .txt file for me but it is not working properly. It just keeps printing the exception error "The file could not be found" and exits the program.
// This program asks the user for input for a name, phone number and notes up to 200 entries. // It stores every contact in a file. Type 'h' for help while running this program.
import java.util.Scanner; import java.io.*; public class Phonebook { static Entry[] entryList = new Entry[200]; static int numEntries; public static void main(String[] args) {
[Code] ....
After running the code, I go into my workspace folder and I see that the file was created. What to do because running the program will always print "could not find the file".
So I'm trying to write a program that will take in 5 numbers, store them in an array and then print out the array and the average of the array. Problem is that every time I run my program I get a "ArrayIndexOutOfBoundsException: 5" error and I don't know who to fix it.
public class ConstructorHomework { final static int size = 5; static double[] myArray = new double[size]; public static double average; public void printArray(){
So for fun I've decided to write a program that can keep track of a simple card game my friends and I designed. I've built a class for an array, that stores the basic stats of each card. I need to be able to access this array from another class, that will print the array information to a file, so we can easily keep track of who's cards have leveled up and their stats. The main class will also be using a random number generator to determine how much damage the attacker/defender deals and takes respectively. So far I have the random number generator built as well. I'm just having issues creating a print to file class and what I need to change in my array class to make it accessible by the other class that prints it to a file.
public class StartingStats { public static void main(String[] args) { //Variable to use for how many spots in a stat array there are final int statArray = 2;
[code]...
what I need to change so that a print to file class can access EACH array in this array folder. Also if any cookie cutter printToFile class I could use/borrow/change that'd be really useful, as I've never done any printing to file before. Also, the levels of each stat and exp will be changing so that's why I need a separate class to print so that I can call it when it's been updated so we always have the most up to date stats saved.
My array isn't printing. I have tried everything. I have tried putting a nested for loop in different methods but still no luck. I have also tried System.out.print but that prints random characters/numbers.
import java.util.Scanner; public class Square { public static void main(String[] args)
[Code].....
^For some reason the site doesn't show the spaces between the *. It's supposed to be a 5x5 square.
I am still having trouble with printing an amortization table for my program. This is the example the professor gave us and our program has to print exactly like this:
Please enter the amount of the loan (a number less than $1,000,000.00) 1000.00 Please enter the annual interest rate (between 2.0 and 15.0 inclusive) 10 Please enter the term of the loan (a number of years between 1 and 30 inclusive) 1 Your monthly payment is 87.92 | INTEREST | PRINCIPAL MONTH 1 : 8.33 79.58 MONTH 2 : 7.67 80.25
[code]....
So far I have it so it works up to the table. How to get it to loop so it will print each month with the principal and interest. This is the part im having trouble with:
I have tried to print array elements using standard print statement. I am getting errors. How to print them. Here is my code:
class arrayEx1{ public static void main(String args[]) { int a[]=new int[3]; //Declaring Single Diomentional Array a[0]=10; a[1]=20; a[2]=30; int total=a[0]+a[1]+a[2]; System.out.println("Values stored in a[0],a[1],a[2]elements are :" + a[0] a[1] a[2]); System.out.println("Total values of a[0],a[1],a[2]elements is :"+ total); } }
if i give comma (,) in between above print stament (print statement 1) stil i am getting errors.
I have a program that works, but I would like to know an easier way to record and print from a large array.
Here is what I have
package pa2; import java.io.IOException; public class PA2Delegate { //long[] array = new long[100000]; int arraySize = 100000; int iterations = 9999; Long[] array;
I am having a hard time trying to figure out how to print random numbers from a an array list. I tried google but nothing worked. I have to pick certain values from two lists and print them on the screen. I have included comments in the code to facilitate the explanation.
import java.util.Random; public class Parachute { public static void main(String[] args) { Random randomNumbers=new Random(); int number; int array []={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21}; char A[] = {'a', 'b', 'c','d','e','f','g','h', 'i','j','k','l','m','n','o','p','q'};
My assignment was to create a class and then write a program that uses the methods of the class I created. All the output is correct except for the Question # Missed. It prints [I@1dd0fe7. The wrong question numbers have to be stored into an array and that array printed. I've tried using a for loop to print, rearranging the code, setting the code to how I did in the other methods. I either get this [I@1dd0fe7 -or- a bunch of 0's. I'm not sure if I am calling the method incorrectly, or just do not have the correct set-up to print the array, or if I am just not grabbing the ones that are incorrect.
public class DriverExam { // Fields private boolean result; private int testTotal; private int numWrong; private int [] numMissed; private char [] answerKey;
public class ArrayPrinter { public static void main(String[] args) { int[] oneD = {5, 6, 7, 8}; PrintArray(oneD); } public static void PrintArray(int[] Arr) { System.out.println ('['); for (int i =0; i >= Arr.length; i++) { System.out.print (Arr[i]); if (i < Arr.length){ System.out.print(", "); } System.out.print (']'); } } }
I tried to format this to enhance readability but I'm not sure if I managed to improve it any... This code should be printing the contents of the array with spaces and commas its just printing [. I think this is because Arr is empty for some reason but I'm not sure why it would be when it gets the values of oneD passed to it.
I am screwing around with mouse listeners so i decided to make a basic paint program. It works fine but when it draws more than 100 circles it errors out. i know why its doing it (its because i set the array to 100) but my question is how to make it so it has not limit in the array.
Here is the code
public class PaintProject extends Applet { int numClicks = 100; int numCicles; int xCoord[]; int yCoord[]; boolean paint;
Iam getting this error at run time while using this command "java mypack.Accountbalance". I have compiled this source code and got its class file that I have put in mypack package but now its showing this error ..
Here's the code : package mypack; class Balance { String name; double bal; Balance(String n ,double b)
[Code] .....
Error: exception in thread "main" java.lang.NoClassDefFoundError: mypack/Ba at mypack.Accountbalance.main(Accountbalance.java:25) used by: java.lang.ClassNotFoundException: mypack.Balance
public class SavingsAccount extends Account { private static final double MIN_BALANCE = 100.00; private static final double RATE = 0.035; public SavingsAccount(Customer customer, double bal, String accountNum, Transaction[] trans) { super(customer, bal, accountNum, trans);
[code]....
When I execute this code there is an error in Transaction array initialization. Change the Saving account constructor from (String customer,double balance, String accountnumber,Transaction[] tr) to (String customer,double balance, String accountnumber,Transaction tr)
I've been trying to finish this blackjack program I have been making for my programming class, however, there are a few bugs I can't seem to iron out. It's a pretty short program, it's just that I'm an idiot and can't figure basic stuff like this out. Specifically, when I try and run it, I get this error:
Error occurred during initialization of VM java.lang.OutOfMemoryError: unable to create new native thread
I have an arraylist, list, that I need to take the size to declare an array, arr3, in another class. Problem 1: the size is giving me an error of "can not make static reference to non-static method getListSize() from the type FindItemInfo". I tried to change getListSize() to static and it gives me and error another place. I try to then fix that, and I get a new error... and so on.
I am using arr3 to store items the user can not afford. I have this next problem even when I input an integer for the arr3 size. I am getting a NullPointerException, and I can't figure out why the arr3[] is not loading. I tried debugging but can not figure out where I went wrong, especially since this code was working in the last assignment before I changed list[] to an arrayList. It always breaks at line 64, but I believe it has to be somewhere in the cashOut() method.
Relevant code is:
public class FindItemInfo implements InterfacePrint{ ArrayList <ItemAttribute> list = new ArrayList<ItemAttribute>(); //does stuff public void printPriority(){ TransactionCalc finish = new TransactionCalc();