User Profile
Collapse
-
Sadly, I only marginally got this program to work. Even after the buttons were fixed, it still was a mess. So I'm trying a simpler program right now and will attempt the inventory program again later. Thanks rotaryfreak for trying to help. :) -
JButtons and maybe JTextArea not working
I've hit a brick wall. I have an GUI inventory program that has three buttons and one textarea. I can get the GUI to appear and the input is correct. But my buttons won't work. When I click the Next button, I should see the next inventory item. Previous doesn't work and neither does Exit. And I a have a sinking feeling that there's something wrong with the logic to modify the textarea, but until the buttons function I can't be sure. Can anyone... -
error <identifier> expected
Hello again folks. I have an error that I can't figure out. Here's my but of code, I can post the whole thing if necessary, but the program is getting big.
Code:private RandomAccessFile output; private String NUMBER_OF_RECORDS; //Create a product CD myCD = new CD( "", 0, 0, 0.00, 0.00, "Band" ); //Get the length of the array NUMBER_OF_RECORDS = JOptionPane.showInputDialog(
-
Never mind folks, someone suggested the compareTo() method and that solved everythingLeave a comment:
-
bad operand '<' I can't compare two Strings
I'm getting a bad operand types for operator <. first String. second string.
I get want the error means, so I'm assuming that I can't use this operator to sort my array of objects. Is there some other way for me to sort this array out. I need to sort the array by the Artist name.
Here's my new code
Code:public class Product { //DECLARE VARIABLES private String number; //Item Number of product(
-
Why is my type unexpected? required variable found value
I'm trying to sort an array of object by the name of the Artist. But I keep getting an error message. Why am I getting this message?
Code://Program to Display Inventory /*Tiffany Walker IT215 Java Programming October 6, 2011*/ import java.util.Scanner; //allows user input import java.util.Arrays; //allows us to add to the array public class InventoryDisplay { //Main
Last edited by Niheel; Oct 15 '11, 10:53 AM. Reason: error details pertaining to quetion merged with question -
Got the answer.
total += inventory[counter].value( CD.getPrice(), CD.getUnits());
This properly adds the value through the array!Leave a comment:
-
Code:for ( int counter = 0; counter < inventory.length; counter++ ) { System.out.println( inventory[counter ] ); }
Leave a comment:
-
When I run the code, I get an output that shows the product#, name, price, amount, and value for each product in the array. The value show up and are correct. But when I try to add the values together (using the various versions of code I tried) either I get 0.00, or the only the last value calculated, or the last value times the array.length.Leave a comment:
-
It wasn't working either way, but I figured try each. I've exhausted anything I thought was the problem. I'm just trying anything at this point. Desperation...Leave a comment:
-
This is the changed code.
Code://Using inventory.length as a counter, loop input and output for ( int counter = 0; counter < inventory.length; counter++ ) { System.out.print( "What is the product number of the CD? "); String theNumber = input.next(); CD.setNumber( theNumber ); System.out.println(); System.out.print( "What is the name of the Artist? ");
Leave a comment:
-
CD is an object made from Product class. Inventory[] is filled with CD's. I tried moving the total calculation to the other loop, but it didn't work.
If you were trying to add data in array together, how would you go about it. Perhaps I'm tackling the problem the wrong way.Leave a comment:
-
My loop isn't working
I'm making an inventory program for class. It has a loop that should cycle through the array and print the information. Part of the loop is supposed to add the value from each inventory item together to get the total value of the inventory. However, instead the program simply adds the last value entered to itself repeatedly. There is no compiler error, but the program isn't doing what it should.
Here is my code for the Product...
No activity results to display
Show More
Leave a comment: