User Profile
Collapse
-
Ah! Thank you very much. :) -
How to reverse lines using LinkedList?
Hi, I'm writing a program that reverses the lines of a String using the LinkedList structure, which includes an iterator. I have my code written out, but every time my program runs, it takes a very long time before it outputs the lines. I'm having difficulty proceeding to the next step. If anyone could point me to the right direction on what to do next, I would greatly appreciate it.
Also note: I'm unable to call the reverse() method... -
Ah, no. It does exist. I just excluded it from my code to make it as small as possible. I apologize that it exceeds 20 lines.Leave a comment:
-
How to output basic arithmetic operations correctly?
I'm creating a program that adds and subtracts fractions together. That being said however, my program does not seem to be responding correctly. Every time I run the client code, it outputs
4/4, when I want it to add 1/2 and 1/2 (instead of 1), and 6/36, when I subtract 2/6 and 1/6 (instead of 1/6). My constructor code and client code is as follows:
...Code:// Constructor // public class RationalNumber { int num; -
Trouble with arrays
I'm trying to make a program that determines whether the score entered is passing (higher than 70.0) or failing (lower than 70.0). The array I'm using needs to be declared as
so that every compartment in the array contains a real number between 0.0 and 100.0 inclusive.Code:double[] scores = new double[50];
...Code:public class Test { public static void main(String[] args) { double[] -
FileRead.java:79: cannot find symbol
I'm writing a program that reads information from three seperate classes. Here is my code:
...Code:public class Animal { protected int id; protected String type; protected double mass; //------------------------------------------------------------------------ // Sets up an animal with the specified ID number, type and weight. //------------------------------------------------------------------------ -
Distinguishing integer numbers from if statements?
I'm writing a program that reads information from three seperate classes. Here is my code:
...Code:public class Animal { protected int id; protected String type; protected double mass; //------------------------------------------------------------------------ // Sets up an animal with the specified ID number, type and weight. //------------------------------------------------------------------------ -
Program won't store integer from seperate file
As the title of the question states, my program is not able to store an integer from a seperate text file provided. For instance, instead of printing the desired output:
"$45.00 17 2222 Chuck Taylor All Star"
It prints:
"$45.00 17 0 Chuck Taylor All Star"
So even though I provided the price (double), quantity (integer) and name (string), my program can store all... -
-
The input is an integer whose value is zero. My program doesn't allow me to add any information in, it just displays the above message.Leave a comment:
-
Exception in thread "main" java.util.NoSuchElementException
Each time I run the ProgTwo program, it displays:
1. Display one product
2. Display all products
3. Add a new CD
6. Exit
Enter your choice: Exception in thread "main" java.util.NoSuc hElementExcepti on
at java.util.Scann er.throwFor(Sca nner.java:838)
at java.util.Scann er.next(Scanner .java:1461)
at java.util.Scann er.nextInt(Scan ner.java:2091)
at java.util.Scann er.nextInt(Scan ner.java:2050)...
No activity results to display
Show More
Leave a comment: