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.
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.
I have this piece of code, which adds marks into 2 different arrayLists, one for homework marks, and one for examination marks..
ArrayList<Double> homeworkMark = new ArrayList<Double>(); ArrayList<Double> examinationMark = new ArrayList<Double>(); boolean markCheck = true; do{ // the purpose of this try catch is to make sure that the entered mark is a valid number. If the program encounters an exception markCheck will become true and the loop will begin again asking the user to enter the marks. If the marks are all encountered correctly markCheck will be false and the loop will end.
try{ for (int i = 1; i <= amountAssignment; i++ ) { sc.reset(); System.out.print("Homework Mark for Assignment " +(i) + ": "); homeworkMark.add(sc.nextDouble()); System.out.print("Examination Mark for Assignment " + (i) + ": "); examinationMark.add(sc.nextDouble()); markCheck = false;
I wrote code to remove question marks and exclamation points from some text. However, one can find those in my output file. Interesting enough, the periods (full stops) were removed.
import java.util.Scanner; public class TextTokenizer { private Scanner scanner; private String[] removableCharacters = { ".", "?", "!", ":", ";", """, "'" }; public TextTokenizer(char[] texts) { scanner = new Scanner(new String(texts));
I'm new to Java, & am using Eclipse Helios. How do I change the text colour within the Quotation marks "Try Again" to red, or any other colour, so when I run it, it will display the new colour.
I'm trying to make a program that will count each letter like if I put the word
e-1 h-1 l-2 o-1
The problem I'm running into is that if I put something like How now, brown cow? It should give me something like this
b - 1 c - 1 h - 1 n - 2 o - 4 r - 1 w - 4
but it doesn't instead the whole program crashes because of the punctuation marks and the spacing. Is there a way for me to fix that? All I know is that it has something to do with the alphabet[pos(letter)]++;
import java.util.Scanner;
public class CharCount { static Scanner keyboard = new Scanner(System.in); //this method should allow the user to enter a line of text (that should all be lower case) and then go to the printResults method public static void main(String[] args) { String text, character; int count; char letter; int[] alphabet; System.out.println("Enter a line of text:"); text = keyboard.nextLine().toLowerCase();// any text entered will be lower case alphabet=countLetters(text);
public static void main(String[] args) { Scanner Keyboard = new Scanner(System.in); System.out.print("Please enter your name."); String name = Keyboard.next(); name = "name";
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);
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
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:
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;
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?
(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 {
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?
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.
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.
my output fails to display me the 2nd output.Here's my code.
import java.util.Scanner; public class year { public static void main (String [] args) { Scanner console = new Scanner (System.in); System.out.print("Enter the choice of book(A-ABC,D-EFG):"); String x = console.next(); System.out.print("Enter the rate (1-3):"); int y= console.nextInt(); System.out.print("Enter number of kids reading:"); int k = console.nextInt();
[code]....
When I key '0" for kids, it did not appear the second print out. I don't want the first print out to be the output.
import java.util.Scanner; class LeftBottomTriangleNew2 { public static void main(String[] args)
[Code]....
the staircase looks good,however I want to remove the last line and if user chooses 9 i want them to get message "enter number from 1 to 8" and do not print out the staircase.
I have been working through a problem, and I have working what I need to work. However, it prints out to the command line and I want to output to a GUI. I have set up the GUI and everything seems fine there, the problem is when I try to change the output that was coming through the command prompt to a JTextField. I am getting the following error.
The field DataAnalyzerGUI.dataOutput is not visible
I am writing this program for my Java level 1 class. I am able to get it to compile and run, however nothing is outputted. Below are the instructions and the code that I have written.
Instructions:
Write an application that calculates and displays the amount of money a user would have if his or her money could be invested at 5 percent interest for one year. Create a method that prompts the user for the starting value of the investment and returns it to the calling program. Call a separate method to do the calculation, and return the result to be displayed.
Below is the code that I have written
import java.util.Scanner; public class Interest { //main method public static void main(String[] args) { originalAmount(); Scanner input = new Scanner(System.in);