Infile Output - Only Giving One Name Two Times

May 7, 2014

I am having issues with the first part of my program. When I got to display what is in the textfile, it only gives me one name two times. I cannot figure out what to do with my outer loop in order for it to read and output the entire data file.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.util.Scanner;
import java.io.*;
import java.text.*;
import java.math.*;
import java.util.StringTokenizer;

[Code] ....

View Replies


ADVERTISEMENT

Output Giving Question Marks?

Feb 6, 2015

I am testing a code given by my lecturer and the output it gives me are all question marks? Heres the code:

package assignment;
import java.util.Random;
public class DeckOfCards { // begin DeckOfCards data type

// playing cards of deck of cards
private PlayingCard[] deck;

[code]....

View Replies View Related

Output Is Not Giving Proper Result - Semantic Error?

Oct 5, 2014

why the output is not giving the proper result? Is this a semantic error?

public class Programming1Practice {
/* testing out instantiation and object oriented programming */
public static class staticValues {

[Code]....

View Replies View Related

Java Swing- After Pressing JButton It Is Not Giving Error Nor Output

May 15, 2014

Problem: On the form window, after pressing the button, it doesn't give any error and doesn't give any output. It doesn't reply and i have to stop compiling to exit. Why does the IDE do that, is it about my Java codes or Form Window codes ? ( I have two classes named Lexical.java and window.java. Working with Eclipse)

Details: I am working on a project that makes Lexical and Syntax analiysis of commands written in SQL Language. My form is in the attachment. If will be necessary i'll put my codes too.

Attached image(s)

View Replies View Related

Keep Track Of Output - How Many Times Each Total Occurs

Jan 23, 2015

I am currently truing to make this class instantiate 100,000 dice rolls of 2 dice. And I also need to keep track of how many times each possible total occurs and I am having trouble outputting the result. Right now when I run my code it is just showing the results of each of the 100,000 roles.

public class ltefera_DiceRollTest {
public static void main(String[] args) {
ltefera_DiceRoll diceRoll = new ltefera_DiceRoll(10);
System.out.println("Total # of pips" + "
");
diceRoll.printArray();
System.out.println(diceRoll.countDice(2));
System.out.println(diceRoll.isArrayDataValid());
System.out.println(diceRoll.getTotal());
System.out.println(diceRoll.allDifferent());

[code]....

"how many time each possible total occurs"

View Replies View Related

Why Java Is Giving Error For Symbol

Sep 28, 2014

I am having trouble figuring out why java is giving me an error for the symbols. I will post the errors below the code.

Java Code: import java.util.Scanner;
public class ShelbyHarms_3_02 {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);

[code]....

View Replies View Related

Window Should Pop Up Giving Properties Of Javac

Feb 20, 2014

I have just tried to learn java this week [COLOR="#000000"]and I am being held back by this once installed java jdk I nav to the java file and the bin file and then the javac file to find that the below tab does not exist

A new window should pop up giving the properties of the javac, there should be an attribute called Location..I can see the location option in my documents but in no other folder

View Replies View Related

Java Program Using Apache POI Giving Exceptions

May 13, 2015

I am having some serious difficulty getting my project off the ground. I have the following code:

FileInputStream file = new FileInputStream(new File("src/retestchecker/test_sheet.xlsx"));
//Get the workbook instance for XLS file
XSSFWorkbook workbook = new XSSFWorkbook(file);
//Get first sheet from the workbook
XSSFSheet sheet = workbook.getSheetAt(0);
Row row = sheet.getRow(0);
Cell x = row.getCell(3);
System.out.println(x);

Everything is properly imported, etc etc.. But I am getting this error and I am not sure what it means:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
at retestchecker.RetestChecker.main(RetestChecker.java:23)
Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)

[Code] .....

Java Result: 1

I am using Netbeans and the latest version of Apache POI that was released May 11, 2015.

The line 23 that the error refers to is this line:

XSSFWorkbook workbook = new XSSFWorkbook(file);

View Replies View Related

JavaFX 2.0 :: App Hangs Without Giving Any Error Information

May 6, 2015

I have an app that is randomly hanging it doesn't give any error information when it hangs.
 
Is there at way to see what's going on when it hangs? e.g. the methods that are being called, where is the program execution at..

View Replies View Related

Random Generator Method Is Not Giving Correct Average?

Aug 4, 2014

Create an array that will store 7 temperatures.

Populate the array with 7 random temperatures from 1 to 100 degrees. (hint use a for loop and a Random number Generator)After the temperatures are in the array, calculate the average of the temperatures in the array.

Print out the average.Print out each temperature in a statement comparing it to the average such as:

The average temperature is 48.94

Temperature 1 is 5.0 and is below average.

Temperature 2 is 67.8 and is above average.

import java.util.Random; 
public class ArrayOfTemperatures
{
public static void main(String[] args) {
// Declare an array
int[] randomtemps = new int[7];
temps[0] = 45;

[code]....

View Replies View Related

Numbers Divisible By 6 - Code Is Giving Different Result Then Expected

Aug 22, 2014

I am having problems with writing a simple program to see if a number is divisible by 6.

public void run() {
println("This program will display all numbers divisible by");
println(" 6 between 1 and 100.");
int x =1;
boolean divide =(x%6==0);

[Code] ....

It is telling that every number is not divisable by 6?

View Replies View Related

Finding Longest Increasing Sequence Not Giving Proper Result

Jan 28, 2015

Okay so I need to be able to read a file and then be able to find the longest sequence of increasing numbers.

So if the file was this, (this is Ass1Q2_test4.txt)

97 47 56 36 60 31 57 54 12 55
35 57 41 13 82 80 71 93 31 62
89 36 98 75 91 46 95 53 37 99
25 45 26 17 15 82 80 73 96 17
75 22 63 96 96 36 64 31 99 86
12 80 42 74 54 14 93 17 14 55
14 15 20 71 34 50 22 60 32 41
90 69 44 52 54 73 20 12 55 52
39 33 25 31 76 45 44 84 90 52
94 35 55 24 41 63 87 93 79 24

the output should be,

(5,0) with cost 12
(6,0) with cost 14
(6,1) with cost 15
(6,2) with cost 20
(7,2) with cost 44
(7,3) with cost 52
(7,4) with cost 54
(6,3) with cost 71
(5,3) with cost 74
(4,3) with cost 96

Greatest path is of length 10.

Now, the code that I have works, kind of. Instead of recurring several times at each point, it only recurs once.

So say I'm looking at (1,1). With (1,1) being 57. The area around it looks like this.

97 47 56
35 57 41
89 36 98

Now when I look at it, there are several paths it can take. It can go 57, 97 or 57, 89 or 57, 98. However, I'm pretty sure that it just uses the first one that corresponds with the first if statement that is valid. So I start checking north of the value, then northeast, then east, then southeast, which at southeast is where I find my first greater than value. After it finds it's first valid number, it then continues from that number, instead of checking if there are other longer paths stemming from the original value.

In conjunction with that, you can see that the printout just returns all paths from each value. Which isn't what I want. I need a way to store the longest current path, then check each path after to see if it's longer. If it is, it's replaced, if not, it stays the same.

I've also attached Ass1Q2_test4.txt

import java.util.*;
import java.io.*;
public class MaxIncreasingSub {

[Code].....

View Replies View Related

Simple Program Giving Negative Result For Amount Of Calculations Done

Mar 5, 2014

Why this extremely simple program seems to be giving me a negative value for amount of calculations done within one minute ( Just using it as a bit of fun to see how different computers in the office perform).

Java Code:

class Benchmark {
public static void main(String[] args) {
long endTime = System.currentTimeMillis() + 60000;
int count = 0;
for (int i = 0; System.currentTimeMillis() < endTime; i++) {
double x = Math.sqrt(System.currentTimeMillis());
count = i;
}
System.out.print(count + " calculations per minute");
}
} mh_sh_highlight_all('java');

I am getting results between -2.1billion and -3.4billion which to me would make sense since they are not the best computers in the world but I would be expecting a positive value?

View Replies View Related

JSF :: ValueChangeEvent NewValue Method Giving Wrong Value When Component Values Change Indirectly

Aug 1, 2014

My form looks like this:

<h:form>
<h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
<p:outputLabel for="filetype" value="FileType: " />
<p:selectOneRadio valueChangeListener="#{selectView.changeServerAndSignmethod}" onchange="submit()" id="filetype" value="#{selectView.filetype}">
<f:selectItems value="#{selectView.filetypes}" itemLabel="#{filetype}" itemValue="#{filetype}" />
</p:selectOneRadio>
<p:outputLabel for="signmethod" value="Sign Method: " />
<p:selectOneMenu valueChangeListener="#{selectView.changeServers}" onchange="submit()" id="signmethod" value="#{selectView.signmethod}">
<f:selectItems value="#{selectView.signmethods}" itemLabel="#{signmethod}" itemValue="#{signmethod}" />

[code]....

As you can see there are two listener in my xhtml file one for filetype and other for signmethod. When filtype changes signmethod has to change which in turn changes servers. And if user changes signmethod using dropdown then also server should change. But my problem is when filetype changes, both the listeners are called, as signmethod also changea but the value in event object (e.getNewValue()) is not the new one but old one. Here is the SelectView Bean.This is the static initialisation part just for checking the output at the end of question.

static {
initFiletypes.add("Windows");
initFiletypes.add("Mobile");
initFiletypes.add("Mac");
initFiletypes.add("Solaris");
initFiletypes.add("Jar");

windowsSignmethods.add("Microsoft");
windowsSignmethods.add("Driver");
windowsSignmethods.add("Driver_Pagehash");
windowsSignmethods.add("HDR");
windowsSignmethods.add("Java2");
windowsSignmethods.add("Javame");
windowsSignmethods.add("MicrosftApps");

[code]....

I am changing servers in changeServerAndSignmethod by selecting first signmethod from signmethod arraylist which is giving correct result. But changeServers is also getting fired taking wrong event object's newValue method and changing servers to wrong values. When changeServers is fired bydirectly changing signmethod, by dropdown, it gives correct result. Is there a way I can stop changeServers to fire when the change came from changing filetypes rather than direct change by user on signmethod selectOneMenu.

View Replies View Related

Reading Json Of Nested Menu Without Giving Menu Names In Java

Aug 14, 2014

I want to read json file as follow;
 
{
  "M": {
  "row": [
  {
  "col1": "c00"
  },
  {
  "col1": "c10",
  "col2": "c11"
  },
  {
  "col1": "c20",
  "col2": "c21",
  "col3": "c22"
  }
  ]
  }
}
 
Next to reading I need to assign to two dimensional array, but without giving "col1","col2","col3" a lot. 

The array is for example, Array[3][] = {{"c00"},{"c10","c11"},{"c20","c21","c22"}};

View Replies View Related

How To Print String Only Five Times

Feb 11, 2015

I can't figure out how to print this string only five times. I tried to use the * operator, but that doesn't work with strings apparently, unles i'm not importing correctly.
 
import java.lang.String;
public class Looparray
{
public static void main(String args[] {
for (String myStr= "Hello there!";;) {
System.out.print (myStr);
System.out.print("
");
}
}
}

View Replies View Related

JSF :: Saving 2 Times One Form

Feb 22, 2014

I'm trying to save to a table in a database that has only 2 fields, (id, nota) . I want to save the data several times just to click on "save" one look . The code that I have is this:

<h:form id="frmPerso" style="font-size: 13px;">
<h:outputText value="Id 1" />
<h:inputText value="#{vistaEjem.notas.id}" />
<h:outputText value="Nota 1 " />
<h:inputText value="#{vistaEjem.notas.nota}" />

[Code] ....

I was told to use a foreach or for the insertDatos, but not as used..

View Replies View Related

How To Find The Best Time Of 14 Run Times

Oct 19, 2014

I have this code that prints the run time for each for loop iteration but how do I find the fastest time store it in a variable and the print that variable at the end? This is what I have currently.

for (int i = 1; i <= 14; i++) {
int n = (int) Math.pow(2, i);
int[] list = new int[n];
for (int j = 0; j < list.length; j++) {
list[j] = (int) (Math.random() * 2000);
}
int length = list.length;
double radixTime = radixSort(list, length);
System.out.println("For base " + i + " the time was " + radixTime);
}

View Replies View Related

Possible To Set Setter And Getter Various Times

May 8, 2014

I am trying to set my setter and getter various times o that I can store a name, price and value but i can only set it once. Once i try to set again the previous entry resets.I have tried

job = sc.next();
jobdetails.setjob(job);
wage = sc.next();
wageD.setwage(wage);
hours = sc.next();
hourd.sethour(hour);

This sets the values for me and i receive the input i entered but if i try to enter again the input from before is removed.I have searched array lists and tried

[code] List<Object> list new ArrayList<Object>();
list.add(jobname)
list.add(price)
list.add(Event)

out.println(list.get(0));

for (Object s : list) {
out.println(s);
}

For this to work I would have to keep adding list.add. Is there a way I can use the array to add a new item to the list so that when I try to display what I have stored in the setter and getter it will display what I have entered in each time instead of only the last input? or any other way that may be possible to do this?

View Replies View Related

How To Put Values In FloatBuffer At Different Times

Mar 17, 2014

I have to put values in a FloatBuffer at different times. How can I ensure that I put the current value in the lowest free position, that is, the values be in a row, not spaced and of course not overwritten. I guess I have to use buffer.position() but how? I've never used buffers before.

View Replies View Related

How To Make A Program Run Multiple Times

May 18, 2014

I have made a basic math game that asks you questions and tells you if you have answered them correctly or incorrectly. The game runs great! The thing is that it asks you a question one time and after you answer you have to run the program again. I want to get the program to ask ten questions. After that I want to figure out a scoring system for it but the first step is to get it to ask my ten questions. Here is my code.

package pkgnew;
import java.util.Scanner;
import java.util.Random;
public class New {
public static void main(String args[]) {

[Code] .....

View Replies View Related

If Condition Matches Multiple Times

Feb 16, 2015

I'm working on a problem that requires me to generator all possible word combinations based on a 7-digit number as input. Many of the generated "words" will be nonsense, but some with be "NEWCARS", "TAKEOUT", etc... This problem mimics the phone number a company would use to support clients remember that number.

I completed the exercise, but I would like to explore more elegant solutions. Specifically, I've used an IF-THEN-ELSE condition inside of a FOR loop. Here is my working code:

package com.johnny_v.exercises.telephone;
public class WordGenerator {
public static void main(String[] args) {
int numOfTimes = 2187;
String two = "ABC";
String three = "DEF";
String four = "GHI";

[code].....

I receive StringIndexOutOfBoundsException exceptions. I it's because multiple conditions are matched. For example, the indexSix is reset to 0 when row is a multiple of 9. Because row is also a multiple of 3, this condition also executes and then increments "indexSix".

View Replies View Related

Check How Many Times Char Is Used In The String

Apr 1, 2014

I tried to make a program that takes a string str, and char a and checks how many times the char is used in the string.

Example: the string Welcome and the letter e, is 2 times. so the program should print 2.

It compiles but when I run it and enter the information, i cannot get the printing line out.

Heres my code:

import java.util.Scanner;
class program
{
public static void main(String[] args) {
Scanner user_input=new Scanner(System.in);
String str;
String b;
System.out.print("Please enter a word");

[Code] .....

View Replies View Related

Servlets :: DoGet Executes 2 Times

Jan 28, 2015

I created a new servlet to download a pdf-file from a unix-server and display it in an iFrame. The servlet gets called, downloads the pdf, throws away the session parameters and then... starts over again. The session parameters aren't there anymore and the servlet returns an error. The strangest thing is, in our development environment the thing works.

web.xml
<servlet>
<servlet-name>iframeservlet</servlet-name>
<servlet-class>Enviro.DownloadIframeContent</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>iframeservlet</servlet-name>
<url-pattern>/jsp/servlet/iframeContent.pdf</url-pattern>
</servlet-mapping>

[code]....

View Replies View Related

Counting How Many Times A Value Appears In Array

Nov 23, 2014

I have this code but I can't seem to get it to work. It keeps saying that "count" cat be found and that it cannot return a value whose type is void.

Java Code: public class Cuantos {
static int getPosition(double listOfValues[], double targetValue ) {
int i,count,
position = -1;
for (i=0; i < listOfValues.length; i++) {
if (listOfValues[i] == targetValue)

[code]....

View Replies View Related

Hot To Get A Swing Timer To Update At Different Times

Apr 27, 2014

I'm working on a space invades game and I have a swing timer set up to update the score(number of aliens killed) and for the aliens to shoot. I'm trying to get the score to update at say 100 ms, but the aliens to shoot at 3200ms. I tried to use 2 timers one for the aliens, and one for the score,but the aliens would just use faster score timer.

import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;

[Code]......

View Replies View Related







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