Array Program Printing Error

Apr 25, 2014

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;

[Code] ....

View Replies


ADVERTISEMENT

Creating TXT File - Program Keeps Printing Exception Error

Apr 10, 2014

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".

View Replies View Related

Comparing 2 Wallets And Printing Each Pair Of Banknotes - Identifier Expected Error

Apr 6, 2014

I'm getting an "identifier expected" error for the following code for comparing 2 wallets and printing each pair of banknotes. Here's the code.

public void printBankNotePairs(Wallet other)
{
StringBuffer myBuffer = new StringBuffer("Pairs: ");
for(int i = 0; i < count; i++)
{
for(int j = 0 + i; j < other.length; j++)

[Code] .....

View Replies View Related

Printing Out Array And Average Of Array

May 2, 2014

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(){

[code]...

View Replies View Related

Printing Array To TXT

Apr 15, 2014

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.

View Replies View Related

Array Isn't Printing?

Nov 17, 2014

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.

View Replies View Related

Printing Amortization Table For Program

Jul 15, 2014

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:

double principal = amount;
double principalPaid;
double interest;
double totalInterest;
double balance = amount;

[code]....

View Replies View Related

Why Program Not Printing Square And Triangle

Nov 21, 2014

import java.util.Scanner;
public class justin10a

public static void main(String [] args)
{
int n;
n = getSize();
 
[Code] .....

View Replies View Related

Printing Product Of Array

Apr 6, 2015

I was having trouble printing the product of the array I am getting runtime errors. Here is part of my code

int [] grades;
grades = new int [10];
grades [0] = 100;
grades [1] = 100;
grades [2] = 100;
grades [3] = 100;
grades [4] = 83;

[Code] ......

View Replies View Related

Printing Array Elements In Java

Oct 15, 2014

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.

View Replies View Related

Printing Index Of Output Array

Feb 6, 2014

I want to Display the Index of output Array.

here is the code:
 
import java.util.ArrayList;
import java.util.List;
public class selection {
private static int[] numbers= { 1, 2, 4, 8, 16, 32, 64, 128, 250, 250, 250, 250, 250, 250, 250 };
private static int[] sumsum= new int[numbers.length];
private static int sum= 1759;

[Code] .....

View Replies View Related

Printing Each Value In Multidimensional Array Using For Loop

Dec 5, 2014

I want to print each value in the multi-dimensional array using a for loop but there is a problem.

Here is the script:

Java Code:

public class LearningJava
{
public static void main(String[] args) {
int[][] Grid = {
{12, 24, 36, 48, 60},
{1, 3, 5},
[Code] ....

Printing i: 0, x: 12
Printing i: 0, x: 24

Exception in thread "main" Printing i: 0, x: 36

Printing i: 0, x: 48
Printing i: 0, x: 60

java.lang.ArrayIndexOutOfBoundsException: 5
at LearningJava.main(LearningJava.java:11)

It's suppose to get the length of each array and print all the values in that array and then move to the next one.

I tried adding .length

Java Code: for(int x = 0; x < Grid[i][x].length; x++) mh_sh_highlight_all('java');

but then it doesn't work at all.

View Replies View Related

Recording And Printing From Large Test Array?

Mar 22, 2015

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;

[code].....

View Replies View Related

Printing Random Values From Array List

Jun 15, 2014

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'};

[Code]...

View Replies View Related

Storing Data In Array And Printing To Screen

Jun 2, 2014

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;

[Code] ....

View Replies View Related

Not Printing Contents Of Array With Spaces And Commas

Nov 7, 2014

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.

View Replies View Related

Unable To Return Array And It Is Printing Out Random Characters?

Dec 21, 2014

This is my code:

public class rotate
{
public static void main(String[] args)
{
int[] arrayInput = {1, 7, 8, 6, 2};
for(int i = 0; i<arrayInput.length; i++)

[Code]...

It's printing out this (the second line):

View Replies View Related

How To Make Paint Program Not Error Out

Oct 14, 2013

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;

[Code] .....

View Replies View Related

Runtime Error In Package Program

Jan 20, 2015

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

View Replies View Related

Compile Error In Hello Java Program

Dec 23, 2014

i wrote this program:

class hellojava
{
public static void main(string[] args)
{
system.out.println("hello java");
}
}

Then i saved this file with name hellojava.java(notepad) in C drive in separate folder c:myjavaapp(not in c:java folder).

When I am compiling(with javac hellojava.java) it shows following error:

cannot find symbol public static void main(string[] args), and also says package system doesnot exists system.out.println("hello java");

View Replies View Related

Error In Array Value Copy

Aug 6, 2014

I am trying to copy all odd value of an array in one array and all even value in another array

this what i have try to so far

private static void arrayOperation(int[] a) {
// TODO Auto-generated method stub
int n=a.length;
int odd_value[] = {};

[Code].....

But i am getting error

View Replies View Related

Error In Array Initialization?

Sep 9, 2014

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)

View Replies View Related

Error In Program To Display Floyd Triangle

Aug 9, 2014

I want to display triangle with for or if loop in java prog as:

1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
.
.
.
79. . . . . . . . . .91

here is code and error file

eror of for: E:Javajdkbin>javac tri.java tri.java:16: error: reached end of file while parsing } ^ 1 error code of above error:

Java Code:

class tri
{
public static void main (String args[]) {
int i,j,a=0; for(i=1;i<=79;i++) {
for(j=1;j<=i;j++) {
a++;
System.out.print(" ");
System.out.print(a);
}
System.out.print("
");
}
} mh_sh_highlight_all('java');

View Replies View Related

Blackjack Program - Error Occurred During Initialization Of VM

May 21, 2014

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

Java Code:

import static java.lang.System.*;
import java.applet.Applet;
import java.util.Scanner;
import java.io.*;
import java.util.Random;
import java.util.Date;

[Code] .....

So, obviously I'm doing something horribly wrong.

View Replies View Related

Program Shows Error While Using Super Keyword

Jan 3, 2015

//constructor
class Base
{
Base(int a) {
System.out.println("in base"+a);;
}
}
class Cons extends Base

[Code] .....

View Replies View Related

Static Error And NullPointerException With Array

Nov 7, 2014

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();

[Code] .....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved