Java help needed-Inventory System
I urgently need help in finishing my java inventory project for school. Can anyone help me usin files and streams to get the program to save data and help me get the menu to work pls THANKS> Heres the source code below:
// TextForm.java
// A simple label/field form panel
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class TextForm extends JPanel {
private JTextField[] fields;
// Create a form with the specified labels, tooltips, and sizes.
public TextForm(String[] labels,
int[] widths, String[] tips) {
super(new BorderLayout());
JPanel labelPanel = new JPanel(new GridLayout(labels.length, 1));
JPanel fieldPanel = new JPanel(new GridLayout(labels.length, 1));
add(labelPanel, BorderLayout.WEST);
add(fieldPanel, BorderLayout.CENTER);
fields = new JTextField[labels.length];
for (int i=0; i < labels.length; i+=1) {
fields[i] = new JTextField();
if (i < tips.length) fields.setToolTipText(tips[i]);
if (i < widths.length) fields[i].setColumns(widths[i]);
JLabel lab = new JLabel(labels[i], JLabel.RIGHT);
lab.setLabelFor(fields[i]);
labelPanel.add(lab);
JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
p.add(fields[i]);
fieldPanel.add(p);
JScrollBar JScrollBar = new JScrollBar();
JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);
add(vbar, BorderLayout.EAST);
public String getText(int i) {
return( fields[i].getText() );
public static void main(String[] args) {
String[] labels = { "115ml Medicine", "236.60ml Water-clear", "236.60 Water-Amber", "250ml Irish Moss",
"250ml Sauce", "355ml Water", "380ml Juice", "473ml Vinegar", "500ml Water", "500 ml Blue Water", "600ml Water",
"750ml Syrup/honey", "900ml Disinfectant", "1000ml Syrup", "1500ml Water", "Total # caps:" };
int[] widths = { 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 ,12 };
String[] descs = { "", "Enter Quantity" };
final TextForm form = new TextForm(labels, widths, descs);
JButton submit = new JButton("Save Inventory");
JButton cancel = new JButton( "Cancel");
submit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showConfirmDialog(null,"Are you sure you want to save this record?");
JOptionPane.showMessageDialog(null, " Inventory status updated");
JOptionPane.showConfirmDialog(null, "Do you want to exit?");
JFrame f = new JFrame("Sweet Inventory System");
f.getContentPane().add(form, BorderLayout.NORTH);
JPanel p = new JPanel();
p.add(submit);
f.getContentPane().add(p, BorderLayout.CENTER);
f.pack();
f.setVisible(true);
Its error free except i cant see the menubar or get it to save items usin files and streams.
HELP PLEASE
TELL ME THE CODE I CAN USE TO MAKE IT SAVE ITEMS LIKE
IN A TEXT FILE AND HOW CAN I ATTACH IT TO THE SAVE
BUTTON USIN A LISTENER
THANKS
PLS POST HEREPosts like this make me ignore you forever.
Similar Messages
-
Help need on System setup for java programming
HELP BADLY NEEDED!
I recently installed java (jdk version8 152mb) on my HP630 win7 because i want to learn java. But when practising, after using notepad to code samples like "Hello Word" and saving it with .java format, it still cannot run on my pc.
Pls i think i need a complete and comprehensible guide on how to install and prepare my win7 laptop for java programming.
Thanks in anticipationHello,
one suggestion is to ensure your system's environment PATH has the Java installation path included, so that it knows where to look to run Java.
(See attached pix).
1st) Find out where Java was installed to on your system: For example, on my Win7 PC, Java was installed to 'C:\Program Files (x86)\Java' directory.
However, my path to the actual binaries is 'C:\Program Files (x86)\Java\jre7\bin'; this is the value I added to my system PATH.
2nd) Check what your System's PATH has: You can do this by looking at the Environment Variables under System Properties:
1) Search for Control Panel, then go to System & Security, then to System, then to 'Advanced System settings'.
2) Click on 'Environment Variables...'
3) Under the 'System variables' pane, use the scroll bar to find 'Path', and click on 'Edit...'.
4) Here is where you add your Java path (as noted above): Note that I appended my java path to the existing Path text, taking care to separate the previous path with a semi-colon (';').
For example, this was my existing 'Path': "C:\Program Files\CollabNet\"...and now it looks like this 'C:\Program Files\CollabNet\;C:\Program Files (x86)\Java\jre7\bin'.
5) Click OK, OK, OK out of all those dialogs.
Now..restart your JVM or attempt to run your Java program!.
Good luck.
Regards,
HardCopy (I am employed by HP) [If this was helpful, please mark this 'Solved' or 'Accept as Solution' so others can find this too]
How to Give Kudos | How to mark as Solved
Attachments:
SystemVariables.PNG 60 KB -
Need help with Inventory System
I am trying to throw together a semi-elegant inventory
viewing system for a web site I am creating. The current website is
going to be scrapped and remade relatively soon, so I really just
want a quick and dirty solution. As such, I have been using some
spry with xml datasets. I happened upon an article
here
that clued me in to a particularly interesting method of presenting
the data, so I am attempting a similar design, along with code from
spry samples (lots of cut-n-paste unfortunately, which is probably
a major reason why I have so many problems). Anyway, here is the
relevant info:
Right now I have folders for each category, with an xml file
for each size category. I arranged it this way, because I was
originally going to use straight html files for each size category
and in each folder, obviously not very practical. I played around
with the idea of putting all sizes into one file and letting some
spry+xml magic sort it out, but since I can't even get this to work
I haven't really tried it. If you experts would clue me in as to
which version might be more efficient or if you have any other
ideas please feel free to put me in my place.
Before I go any further, my main problem is the third line of
the first piece of code, I'm having trouble getting the dsStock xml
to load properly. The original example I cited above was using
Coldfusion, but I guesstimated that it wouldn't be a problem to
just load some straight xml files. Before I go any further I would
at least like to know if what I am attempting is possible.
Code to load in data for menus, category selection, and
actual inventory etc........
quote:
var dsCategories = new Spry.Data.XMLDataSet("diamond.xml",
"diamonds/diamond");
var dsSize = new Spry.Data.XMLDataSet("size.xml",
"sizes/size");
var dsStock = new
Spry.Data.XMLDataSet("{dsCategories::@id}/{dsSize::name}.xml",
"inventory/product");
diamond.xml
quote:
<?xml version="1.0" encoding="utf-8"?>
<diamonds>
<diamond
id="AS"><name>Asscher</name><img>../img/diamond/thumb/asscher_diamond_chicago.jpg</img></ diamond>
<diamond
id="CU"><name>Cushion</name><img>../img/diamond/thumb/cushion_diamond_chicago.jpg</img></ diamond>
</diamonds>
size.xml
quote:
<?xml version="1.0" encoding="utf-8"?>
<sizes>
<size><name>0.70-0.99</name></size>
<size><name>1.00-1.49</name></size>
</sizes>
snip of some inventory
quote:
<?xml version="1.0" encoding="utf-8"?>
<inventory>
<product
id="B801-508"><shape>Asscher</shape><weight>0.7</weight><color>G</color>
<clarity>VVS2</clarity><depth>71.1</depth><table>61</table><flo>None
</flo><polish>Excellent</polish>
<symmetry>Very
Good</symmetry><dim>4.97x4.77x3.39</dim><price>2592.1</price>
</product>
<product
id="B800-125"><shape>Asscher</shape><weight>0.7</weight><color>G</color>
<clarity>VS1</clarity><depth>68.2</depth><table>58</table><flo>None
</flo><polish>Very Good</polish>
<symmetry>Very
Good</symmetry><dim>4.93x4.78x3.26</dim><price>2366.7</price>
</product>
</inventory>
Here is the actual code in the site (this seems to work out
alright). I haven't rewritten the actual inventory portion yet,
since I can't really get it to load properly. If I can get the xml
I know that I can get it on the page.
quote:
<ul spry:region="dsCategories"
spry:repeatchildren="dsCategories">
<li class="product" spry:selectgroup="1"
spry:select="selected" spry:hover="hover"
spry:setrow="dsCategories">{dsCategories::name}</li>
</ul>
<ul spry:region="dsSize" spry:repeatchildren="dsSize">
<li class="product" spry:selectgroupd="2"
spry:select="selected" spry:hover="hover"
spry:setrow="dsSize">{dsSize::name}</li>
</ul>
Sorry for the long post, but thanks for taking the time to
give it a read and see if you can help me out. I will be eternally
grateful.Hi StevenMig,
I'm not seeing anything obvious. Have you tried loading your
XML files directly to see if there are errors in the XML? Is your
server serving up XML files with a Content-Type of text/xml or
application/xml?
If you post a sample page, perhaps me or someone else on the
forum can take a look?
--== Kin ==-- -
Psuedocode to java. help needed if poss
i need to convert the following into java, but i am not sure how to output it..
Roll a 12 sided die to choose a number between 1...12
while the user has not made an incorrect guess
ask the user if the next number will be higher or lower
choose random number
if users guess is correct
increment count of correct guesses
update the stored current number
end if
end while
tell the user how many correct guesses there are
any help would be greatful, i am a beginning so go easy!!!
thanks alot
steviehey, sorry if i've caused a 'cross post', i am not too sure what it is but i hope i haven't done anything wrong! so far i am just trying to put a basic program together before building on it..
import java.util.scanner;
public class dice
public static void main (String [] args)
Scanner in = new Scanner(System.in);
Random rnd = new Random();
System.out.print("input a number between one and twelve") int r =in.nextInt;
int r = rnd.nextInt(12) + 1;
System.out.println(r);
i know this has errors, but i was just hoping for a hint/clue for the basic program before researching more to build on it.. hope this code will help. reply when you can, thank you very much
stevie -
Java help needed(PLEASE)
I have a Question for all you gifted people:
I am designing a sort of quiz which takes questions and three possible answers from a database(which also holds the real answer).It prints these on the dos screen and I then have a System.in statement which allows the user to enter his or her answer (eg A,B,C or 1,2,3). I need a way of adding up the score at the end!!I was thinking of storing there answers in an array and compairing there answer to my correct answer in the database and if it is the same add 1 and if it not the same add 0???
How would i write the System.in answers into an array and add them up???
These are my thoughts on how to do this i would love to hear yours!! And also a help with writing the code for the above system of scoreing would be GREATLY appriciated!!
thanks everyone,
james.As mathuoa pointed out, since you already display the 3 possible answers to the user, get them into an array and display them on the screen. Then, as the user enters an answer, compare them with the three answers and if it is correct, update the score variable as such. If you want the history of answers that the user has given, then u will have to use a Vector/List/some such collection object to hold the user's answers.
java.util.Vector answers = new java.util.Vector();
answers.add(usersAnswer1);
answers.add(usersAnswer2);
Then, to get the entries,
for(Enumeration e = answers.elements(); e.hasMoreElements();)
System.out.println(e.nextElement());
//Do something with the answer.
This is one possible way of getting the answers from the user! -
Help needed with system recovery Satellite L300-149
Hi
We have a Satellite L300-149.
Was running really slowly so wanted to reset it to factory settings.
Did the 'press F12 when starting, put disk in' etc etc BUT have a horrible feeling that I put a disk in that actually belonged to a different Toshiba we used to use a U300.
The 'give away' was that the user manual for the U300 is now on the desktop on the Satellite :-/
I hoped that this wouldn't be a major problem BUT the F8 key has now disappeared making it impossible to connect to the internet.
I looked online and read that the L300 sometimes doesn't come with a disk as the info is kept on a separate part of the hard drive so hoped I could reset it back to factory settings again but when I click F2 on start up and go to the option to restore it, noting happens.
Can anyone please help??????Hi
Forget the HDD recovery now
You have recovered the system using another disk and this has deleted the HDD recovery image files. So this option is NOT possible!
You are right the L300 and all other notebooks are not delivered with Recovery disks.
The recovery disk has to be created using the preinstalled software called Recovery Disk Creator. But this is also NOT possible because you removed the preinstalled system and the files which are needed for such recovery disk are not available anymore!
But if everything work properly except of the WLan FN + F8 key, then I would recommend to install only the Wlan driver. I think the key does not work because the right WLan driver is not installed.
I think the Satellite L300-149 supports the Wlan Realtek RTL8187B chip.
So install the right Wlan driver which you can find here:
http://aps.toshiba-tro.de/wlan/?page=downloads -
Calling perl script from java ---help needed
I haven't been doing a lot with java lately and i'm building an app with netbeans and having some difficulty with my button calling an outside perl script I'm pasting the code and error below...any help would be greatly appreciated. It's running on fedora 9 pretty much default install...
thanks.
code:
Runtime r = Runtime.getRuntime();
Process p = null;
String s = null;
String cmd123[] = { "perl /home/deaddev/test1.pl" };
try {
p = r.exec(cmd123);
catch {
foo bar/etc/etc
error:
Oct 12, 2008 4:09:37 PM photomainmgr readToPerlActionPerformed
SEVERE: null
java.io.IOException: Cannot run program "perl /home/deaddev/test1.pl": java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:474)
at java.lang.Runtime.exec(Runtime.java:610)
at java.lang.Runtime.exec(Runtime.java:483)
at photomainmgr.readToPerlActionPerformed(photomainmgr.java:117)
at photomainmgr.access$000(photomainmgr.java:21)
at photomainmgr$1.actionPerformed(photomainmgr.java:54)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:253)
at java.awt.Component.processMouseEvent(Component.java:6101)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3276)
at java.awt.Component.processEvent(Component.java:5866)
at java.awt.Container.processEvent(Container.java:2105)
at java.awt.Component.dispatchEventImpl(Component.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2163)
at java.awt.Component.dispatchEvent(Component.java:4288)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4461)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4125)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4055)
at java.awt.Container.dispatchEventImpl(Container.java:2149)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4288)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:604)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.<init>(UNIXProcess.java:164)
at java.lang.ProcessImpl.start(ProcessImpl.java:81)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:467)
... 30 more
error executing perl /home/deaddev/test1.pljschell wrote:
sabre150 wrote:
As and alternative you can useString cmd123 = "perl /home/deaddev/test1.pl";Using the single string approach YOU have to do any quoting so with this line no quoting takes place and the script /home/deaddev/test1.pl will be executed.Although that should be true apparently it isn't. I have just run
Process p = Runtime.getRuntime().exec("perl /home/sabre/work/dev/perl/xxx.pl");
new Thread(new SyncPipe(p.getErrorStream(), System.err)).start();
new SyncPipe(p.getInputStream(), System.out).run();
int returnCode = p.waitFor();
System.out.println("Return code = " + returnCode);which correctly executes the perl script xxx.pl.
P.S. SyncPipe is a Runnable that copies an InputStream to an OutputStream.
Edited by: sabre150 on Oct 14, 2008 9:19 AM
Interesting! Even though Runtime.exec() works with a single String, ProcessBuilder fails with this approach! You have to split the argument string. This certainly looks like a bug! Some while ago I looked at the source for Runtime.exec() to look at the differences between Runtime.exec() and ProcessBuilder and found that behind the scenes Runtime.exec() uses ProcessBuilder.
More research is required. -
New to Java: Help Needed
Hi,
I am writing a utility to monitor all the objects created by my application. I want to be able to get not only values of class variables(for which the reflection package seems pretty useful), but also instance variables.
For example.
public class myClass {
//Constructor
public myClass(int i) {
// another class instantiates this one
myClass mc = new myClass(10);
myClass mc1 = new myClass(20);
I need to keep track of the the handles mc and mc1 and the
other initializations they do based on the value passed at runtime.
Is there a way to to this. Or even better, is there someplace in Java which stores all the objects instantiated and their handles?
Any suggestions would be greatly appreciated.
Thnx
cvsanHow do I access private and proteced variables. By default only the public variables are accessible via the reflect class as in the example below.
Class c = rc.getClass();
String s = c.getName();
System.out.println(s);
try { abcField = c.getField("abc");
where abc is a public instance variable. If abc is a private instance variable, the above example fails.
Is there any way to override the data hiding feature of Java?
Thanks
cvsan -
*Basic* Java help needed...
I feel like a complete novice for posting this kinda stuff, but i figured somebody would take 5 minutes and help me out. My final in my programming class depends on 2 programs, one of which is giving me some actual trouble.
What I have to do is create a java applet that allows a user to input their weight, select a planet, and then have their weight converted to what their weight would be on the selected planet. However, if the ouput is higher than 60 pounds, I need a picture of the michelin man to appear and the theme from star wars to play. If it is below 60, A multicolored asterisk should be displayed with applause.
I will post what code I have already made. Please note: ITS VERY VERY BASIC. I may have overcomplicated some things, and there is always more than one way to do something (in my experience). Also, I kinda just converted a temperature conversion applet, so there may be some extra stuff I don't need.
Please help.
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class tempsapp2 extends Applet implements ActionListener
Label prompt1;
TextField input1;
Label prompt2;
TextField input2;
int number1, number2;
int mercury, venus, earth, mars, jupiter, saturn, neptune, uranus, pluto, result;
public void init()
prompt1 = new Label ("Enter your weight:");
add (prompt1);
input1 = new TextField (10);
add (input1);
prompt2 = new Label ("Enter the Number of the Planet you would like to have your weight converted to:");
add (prompt2);
input2 = new TextField (10);
add (input2);
input2.addActionListener(this);
add (input2);
public void paint (Graphics g)
number1 = Integer.parseInt(input1.getText());
number2 = Integer.parseInt(input2.getText());
mercury = (number1*3780)/1000;
venus = (number1*9070)/1000;
earth = (number1*10)/1000;
mars = (number1*3770)/1000;
saturn = (number1*9160)/1000;
uranus = (number1*8890)/1000;
neptune = (number1*1125)/1000;
jupiter = (number1*2364)/1000;
pluto = (number1*670)/1000;
if(number2==1)
g.drawString("Your weight on Mercury would be "+mercury+" lbs",100,150);
else if(number2==2)
g.drawString("Your weight on Venus would be "+venus+" lbs",100,150);
else if(number2==3)
g.drawString("Your weight on Earth would be "+earth+" lbs",100,150);
else if(number2==4)
g.drawString("Your weight on Mars would be "+mars+" lbs",100,150);
else if(number2==5)
g.drawString("Your weight on Jupiter would be "+jupiter+" lbs",100,150);
else if(number2==6)
g.drawString("Your weight on Saturn would be "+saturn+" lbs",100,150);
else if(number2==7)
g.drawString("Your weight on Uranus would be "+uranus+" lbs",100,150);
else if(number2==8)
g.drawString("Your weight on Neptune would be "+neptune+" lbs",100,150);
else if(number2==9)
g.drawString("Your weight on Pluto would be "+pluto+" lbs",100,150);
public void actionPerformed(ActionEvent evt)
number1 = Integer.parseInt(input1.getText());
number2 = Integer.parseInt(input2.getText());
repaint();
}I am guessing that you are wondering where to go from here. If so http://java.sun.com/products/plugin/1.5.0/demos/applets/Animator/Animator.java may prove helpful.
Also I would recommend using arrays of planet names and weight multipliers. It could make your code a lot less cumbersome. -
New to java,,,help needed urgently
I am geeting a compile error..."cannot resolve symbol" in my main class. The program is supposed to prompt the user for five sets of data, and calculate the tax and total of the entered products and print it back to the screen, it is also supposed to calculate the cheapest and most expensive item and print them back. can someone pls shed some light on this error msg, as I cant seem to get my head around it.
import java .io.*;
import java.util.StringTokenizer;
import java.text.NumberFormat;
import java.util.Locale;
//set up a class to call on the constructors from the catalogueitem class
public class Myassg4
private static final int MAX = 2;//sets the length to 2
private static CatalogueItem[] prodlist ;//sets array for product list
NumberFormat cash = NumberFormat.getCurrencyInstance(new Locale("en","AU"));
private static void main(String[] args) throws IOException
{//declare the variables and initialize
double preTotal = 0.00;
String inString;
double maximum, lowest;
double sum = 0.00;
BufferedReader stdin = new BufferedReader (new
InputStreamReader(System.in));
prodlist = new CatalogueItem[];//sets the length (THIS IS WHERE THE PROBLEM OCCURS!!!!)
System.out.println("Enter 5 sets of data");
//loop through the array and read the data in
for(int i = 0;i <prodlist.length;i++)
inString = stdin.readLine();
//create a String Tokenizer to read the data separately
StringTokenizer tok = new StringTokenizer(inString, ":");
prodlist[i] = new CatalogueItem(tok.nextToken(), tok.nextToken(),
Double.parseDouble(tok.nextToken()));
}//end of loop
//create a header and print the data back to the screen
System.out.println();
System.out.println("LISTING OF ALL GOODS");
System.out.println();
System.out.println("Cat\tDescription\tExTax\tTax\tIncTax");
System.out.println("___\t___________\t_____\t___\t______");
System.out.println();
for(int j = 0;j <prodlist.length;j++){
System.out.println(prodlist[j].getCatno()+"\t"+prodlist[j].getDesc()+
"\t"+prodlist[j].getPrice()+"\t"+prodlist[j].getTax()
+"\t"+prodlist[j].getIncTax());
I have errors every where the prodlist is used, I know I am not initializing it correctly but dont know what the alternatives are.daniel here is the entire code if you do get a chance can you pls have a look at it for me thanks.
import java .io.*;
import java.util.StringTokenizer;
import java.text.NumberFormat;
import java.util.Locale;
//set up a class to call on the constructors from the catalogueitem class
public class Myassg4
private static final int MAX = 2; //sets the length to 2
private static CatalogueItem[] prodlist; //sets array for product list
NumberFormat cash = NumberFormat.getCurrencyInstance(new Locale("en","AU"));
private static void main(String[] args) throws IOException
{//declare the variables and initialize
double preTotal = 0.00;
String inString;
double maximum, lowest;
double sum = 0.00;
BufferedReader stdin = new BufferedReader (new
InputStreamReader(System.in));
prodlist = new CatalogueItem[5];//sets the length
System.out.println("Enter 5 sets of data");
//loop through the array and read the data in
for(int i = 0;i <prodlist.length;i++)
inString = stdin.readLine();
//create a String Tokenizer to read the data separately
StringTokenizer tok = new StringTokenizer(inString, ":");
prodlist[i] = new CatalogueItem(tok.nextToken(), tok.nextToken(),
Double.parseDouble(tok.nextToken()));
}//end of loop
//create a header and print the data back to the screen
System.out.println();
System.out.println("LISTING OF ALL GOODS");
System.out.println();
System.out.println("Cat\tDescription\tExTax\tTax\tIncTax");
System.out.println("___\t___________\t_____\t___\t______");
System.out.println();
for(int j = 0;j <prodlist.length;j++){
System.out.println(prodlist[j].getCatno()+"\t"+prodlist[j].getDesc()+
"\t"+prodlist[j].getPrice()+"\t"+prodlist[j].getTax()
+"\t"+prodlist[j].getIncTax());
//use this data and call the cheapest method to print
//the cheapest goods in the catalogue
System.out.println();
System.out.println("CHEAPEST GOODS IN THE CATALOGUE");
System.out.println();
lowest = cheapest(prodlist, MAX);
System.out.println("Cat\tDescription\tExTax\tTax\tIncTax");
System.out.println("___\t___________\t_____\t___\t______");
System.out.println();
for(int k = 0;k <prodlist.length;k++){
if(prodlist[k].getTaxInc == lowest)
System.out.println(prodlist[k].Catno()+"\t"+prodlist[k].getDesc()+
"\t"+prodlist[k].getPrice()+"\t"+prodlist[k].getTax()
+"\t"+prodlist[k].getIncTax());
//use the listing of all goods and call the most expensive method
//to calculate and display back on screen
System.out.println();//create two lines of space in between
System.out.println();
System.out.println("MOST EXPENSIVE GOODS IN THE CATALOGUE");
System.out.println();
maximun = expensive(prodlist, MAX);
System.out.println("Cat\tDescription\tExTax\tTax\tIncTax");
System.out.println("___\t___________\t_____\t___\t______");
System.out.println();
for(int l = 0;l < prodlist.length;l++){
if(prodlist[l].getTaxInc == maximum)
System.out.println(prodlist[l].Catno()+"\t"+prodlist[l].getDesc()+
"\t"+prodlist[l].getPrice()+"\t"+prodlist[l].getTax()
+"\t"+prodlist[l].getIncTax());
//print the pretax worth of goods by calling the method and display
System.out.println();//create a two lines of space in between
System.out.println();
System.out.println("TOTAL OF PRE-TAX WORTH OF CATALOGUE ITEMS: "+preTaxWorth
(prodlist));
//print the avg tax payable per item
System.out.println();
System.out.println("AVERAGE AMOUNT OF TAX PAYABLE PER ITEM:"+avgTax
(prodlist));
//declare the other methods within the scope of the main class
public static double cheapest(CatalogueItem[] prodlist, int size)
double lowest = prodlist[0].getIncTac();
for(int i = 0; i < size;i++)
if(prodlist.getIncTax() < lowest)
lowest = prodlist[i].getIncTax();
return lowest;
public static double expensive(CatalogueItem[] prodlist, int size)
double maximum = prodlist[0].getTaxInc();
for(int i = 0; i < size; i++)
if(prodlist[i].getIncTax() > maximum)
maximum = prodlist[i].getIncTax();
return maximum;
public static double preTaxWorth(CatalogueItem[] prodlist)
{//add all the getPrice's in together
double preTax = 0; //prodlist[0].getPrice();
for(int i =0; i <prodlist.length; i++)
preTax += prodlist[i].getPrice();
return preTax;
public static double avgTax(CatalogueItem[] prodlist)
{//run through the array and add all the getTax amounts up.
double sum = 0;
for(int i = 0; i < prodlist.length; i++)
sum = sum + prodlist[i].getTax();
//to get the avg we divide the sum by the MAX number of entries
double Total = sum / MAX;
return Total;
}//end of main class
//CatalogueItem class
//catalogue item class
//ensure that the accesors and mutators
//are visible and cannot be overridden
class CatalogueItem
//declare the data types
private String catno;
private String desc;
private double price;
//declare the taxation rate constant
//but make it visible
public CatalogueItem(){
catno = " ";
desc = " ";
double price;
//declare the full constructor
CatalogueItem (String inCatno, String inDesc, double Price)
inCatno = catno;
inDesc = desc;
Price = price;
//name accessor---not overidable
public final String getCatno()
return catno;
//name product description accessor--not overidable
public final String getDesc()
return desc;
//name the extax method
public double getPrice()
return price;
//tax utility method
public double Tax()
double Tax;
Tax = 00.15 * getPrice();
return Tax;
//Including Tax method
public double IncTax()
double IncTax;
IncTax = Tax() + getPrice();
return IncTax; -
Some java help needed!!!!
Exception in thread "main" java.lang.NullPointerException
at Standings.<init>(Standings.java:15)
at Client.main(Client.java:21)
this is my program and I dont understand what is going wrong, I am also including the 2 classes that complement it.
class 1
public class Team
// Declaring Private Variables
private double wins;
private double loses;
private String Name;
public Team()
Name="";
wins=0;
loses=0;
public Team(String t, double w, double l)
Name=t;
wins=w;
loses=l;
public void setName (String n)
Name=n;
public void setWins (double w)
wins=w;
public void setLoses (double l)
loses=l;
public String getName ()
return Name;
public double getWins ()
return wins;
public double getLoses ()
return loses;
public String toString ()
String toString=Name + " " + wins + " " + loses;
return toString;
public boolean equals (Team p1, Team p2)
if ((p1.Name.equals(p2.Name))&&(p1.wins==p2.wins) && (p1.loses==p2.loses))
return true;
else
return false;
class 2
public class Standings
private Team [] teams;
private String [] steams;
public Standings (Team [] arr)
for(int i=0;i<arr.length;i++)
teams[i] = new Team(arr.getName(), arr[i].getWins(), arr[i].getLoses());
public Team [] toString2 ()
return teams;
client program
import java.text.DecimalFormat;
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
public class Client
public static void main( String [] args ) throws IOException
//first let's create an array of football teams
Team [] array = new Team[5];
array[0] = new Team("Alabama", 6, 6);
array[1] = new Team("Georgia", 7, 4);
array[2] = new Team("Tennessee", 8, 3);
array[3] = new Team("Vanderbilt", 4, 8);
array[4] = new Team("Mississippi", 1, 6);
// now instantiate the team calling the overloaded constructor
Standings temp = new Standings(array);
// now let's print the team (call toString)
System.out.println(temp.toString());
//Standings another = new Standings( temp );private Team [] teams;You never allocated this array, as in:
teams = new Team[size];
so when you get to this line:
teams[ i ] = new Team(...);teams is null, ergo the NullPointerException. -
Help needed Inventory 0IC_C03
Hi guys,
I am presently working on an inventory project.
I have activated the busines content for the whole process flow i.e the cube 0IC_C03 and its respective datasources and infosources.
Now I want to understand the logic thst is being used in the start and update routines.Is there any doc that gives the logic for these routines.
For example a KF 0ISSVALSCRP which exists in the cube 0IC_C03 is mapped from its infosource using the rulename Issue Qty: Scrap - Purch.Val. from Matl Doc. on Posting Date.
The routine used is 'Perform routine_0030'.
which is
IF ( COMM_STRUCTURE-movetype EQ '551' "GI scrapping
OR COMM_STRUCTURE-movetype EQ '552' "GI scrapping
OR COMM_STRUCTURE-movetype EQ '553' "GI scrapping QI
OR COMM_STRUCTURE-movetype EQ '554' "GI scrapping QI
OR COMM_STRUCTURE-movetype EQ '555' "GI scrapping blocked
OR COMM_STRUCTURE-movetype EQ '556' ) "GI scrapping blocked
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
AND COMM_STRUCTURE-cppvlc <> 0 .
Could somebody tell me the logic implemented in this piece of code.Is there any document for the same.
Points will be assigned.
Thanks
AnkitHi guys,
I am presently working on an inventory project.
I have activated the busines content for the whole process flow i.e the cube 0IC_C03 and its respective datasources and infosources.
Now I want to understand the logic thst is being used in the start and update routines.Is there any doc that gives the logic for these routines.
For example a KF 0ISSVALSCRP which exists in the cube 0IC_C03 is mapped from its infosource using the rulename Issue Qty: Scrap - Purch.Val. from Matl Doc. on Posting Date.
The routine used is 'Perform routine_0030'.
which is
IF ( COMM_STRUCTURE-movetype EQ '551' "GI scrapping
OR COMM_STRUCTURE-movetype EQ '552' "GI scrapping
OR COMM_STRUCTURE-movetype EQ '553' "GI scrapping QI
OR COMM_STRUCTURE-movetype EQ '554' "GI scrapping QI
OR COMM_STRUCTURE-movetype EQ '555' "GI scrapping blocked
OR COMM_STRUCTURE-movetype EQ '556' ) "GI scrapping blocked
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
AND COMM_STRUCTURE-cppvlc <> 0 .
Could somebody tell me the logic implemented in this piece of code.Is there any document for the same.
Points will be assigned.
Thanks
Ankit -
Set Pasword in any folder through java (HELP NEEDED)
hi i want know it is possibel in java i m set password in any folder of my windows if it is so reply me soon .
i m waiting for replyIn java only - no.
If there is a command line tool that does it then you can use Runtime.exec() with an OS specific command. Presumably you are talking about windows so you might look in the appropriate resource kit. That is probably the most likely location for a command. But it could be somewhere else too.
If you can't find a command then you would have to use JNI. -
Beginning Java help needed.
I'm trying to write a program that would display the elapsed time after double clicking in seconds. For instance, first click will start the timer, but it will not display the elapse time after the second click. Here is my code.
public class ClickTimer extends WindowController {
private double startingTime;
private Text message;
public ClickTimer () {startController (700,500);
public void begin() {
message = new Text( "Double click twice to display time elapse." ,50, 50
,canvas );
public void onMousePress(Location point) {
startingTime = System.currentTimeMillis();
if (point.getclickCount() == 2) {float elapsedTimeSec = elapsedTimeMillis/1000F;
}}For instance, first click will start the timer, but it will not display the elapse time after the second click.Since there's no code there that would display elapsed time, that isn't surprising.
Your onMousePress method always sets the startTime value (no matter what click it is), which is probably not what you want.
Text? Location? WindowController? What library are you using? You should say up front. -
In the below program i want to place some code and i need to know what code to place and where. I want the code to speed up the program by 50 times what it is know.
Its quite a hard question since if asked alot of people and they don't seem to know.
import SpikeLib.*;
public class SpikeOctagon
public static void main (String args [] )
SpikeWindow window;
Spike mySpike;
mySpike = new Spike ();
window = new SpikeWindow ();
window.addSpike (mySpike);
mySpike.setColour (Spike.RED, Spike.PINK);
mySpike.moveNorth();
mySpike.moveNorth();
mySpike.moveNorth();
mySpike.moveNorthWest();
mySpike.moveNorthWest();
mySpike.moveNorthWest();
mySpike.moveWest();
mySpike.moveWest();
mySpike.moveWest();
mySpike.moveSouthWest();
mySpike.moveSouthWest();
mySpike.moveSouthWest();
mySpike.moveSouth();
mySpike.moveSouth();
mySpike.moveSouth();
mySpike.moveSouthEast();
mySpike.moveSouthEast();
mySpike.moveSouthEast();
mySpike.moveEast();
mySpike.moveEast();
mySpike.moveEast();
mySpike.moveNorthEast();
mySpike.moveNorthEast();
mySpike.moveNorthEast();
cheersI know how to get that 50X speedup. It's easy - get a computer that's 50X faster than the one you're running on now.
This is one of the worst requests I've seen posted in a while. The OP is a total, utter eejit. NO ONE would be able to make a start on this preposterous question based on the code that's been posted.
If the quality of the question is indicative of the quality of the code, no one it's a slow pig. - MOD
Maybe you are looking for
-
I upgraded my Icloud storage capacity to a higher tier and my Iphone does not reflect the change although my credit card was charged and the device is nor properly backup. How can this be resolved?
-
Using 'For Each' Method in re-usable ADF library application
I'm trying to build a re-usable RSS library application from the following (using JDev Studio Edition Version 11.1.1.4.0 on Windows 2008 Server): http://blogs.oracle.com/dana/entry/reusable_adf_library_rssfeedre I'm bascially creating the application
-
Xcelsius drill down problem.
Hi gurus, I'm developing drill down chart and table. I want to reset, making cell blank, the drill down cell when i click combo box. I used push button to refresh or reset drill down value but it can not refresh(reset) drill down cell because the des
-
Oracle recommends that you revoke EXECUTE privileges on powerful packages f
Oracle recommends that you revoke EXECUTE privileges on powerful packages from PUBLIC Got on error on the home page of Enterprise Manager and read that I should run the code below to correct the problem, but when I click on the link at the bottom of
-
Question regarding standard BAPIs used to change quotes etc.,
Hello friends Are SAP BAPI calls for quote change the same for ECC and CRM? We are trying to get more info on standard BAPI such as BAPI_CUSTOMERQUOTATION_CHANGE. I heard that SAP Accelerator Web Service may not work for changing quotes in CRM. Any