473,699 Members | 2,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't get my inventory program to compile

59 New Member
I have a java class that goes for another week or so, and I am going to fail if I can't figure out this simple program. I can't get anything to compile to at least get a few points... Here are the assignments...

4. CheckPoint: Inventory Program Part 1
• Resource: Java: How to Program
• Due Date: Day 5 [Individual] forum
• Choose a product that lends itself to an inventory (for example, products at your
workplace, office supplies, music CDs, DVD movies, or software).
• Create a product class that holds the item number, the name of the product, the number
of units in stock, and the price of each unit.
• Create a Java application that displays the product number, the name of the product, the
number of units in stock, the price of each unit, and the value of the inventory (the
number of units in stock multiplied by the price of each unit). Pay attention to the good
programming practices in the text to ensure your source code is readable and well
documented.


1. CheckPoint: Inventory Program Part 2
• Resource: Java: How to Program
• Due Date: Day 4 [Individual] forum
• Modify the Inventory Program so the application can handle multiple items. Use an array
to store the items. The output should display the information one product at a time,
including the item number, the name of the product, the number of units in stock, the
price of each unit, and the value of the inventory of that product. In addition, the output
should display the value of the entire inventory.
• Create a method to calculate the value of the entire inventory.
• Create another method to sort the array items by the name of the product.


2. CheckPoint: Inventory Program Part 3
• Resource: Java: How to Program
• Due Date: Day 7 [Individual] forum
• Modify the Inventory Program by creating a subclass of the product class that uses one
additional unique feature of the product you chose (for the DVDs subclass, you could use
movie title, for example). In the subclass, create a method to calculate the value of the
inventory of a product with the same name as the method previously created for the
product class. The subclass method should also add a 5% restocking fee to the value of
the inventory of that product.
• Modify the output to display this additional feature you have chosen and the restocking
fee.


4. CheckPoint: Inventory Program Part 4
• Resource: Java: How to Program
• Due Date: Day 5 [Individual] forum
• Modify the Inventory Program to use a GUI. The GUI should display the information one
product at a time, including the item number, the name of the product, the number of
units in stock, the price of each unit, and the value of the inventory of that product. In
addition, the GUI should display the value of the entire inventory, the additional attribute,
and the restocking fee.


2. CheckPoint: Inventory Program Part 5
• Resource: Java: How to Program
• Due Date: Day 7 [Individual] forum
• Modify the Inventory Program by adding a button to the GUI that allows the user to move
to the first item, the previous item, the next item, and the last item in the inventory. If the
first item is displayed and the user clicks on the Previous button, the last item should
display. If the last item is displayed and the user clicks on the Next button, the first item
should display.
• Add a company logo to the GUI using Java graphics classes.

Here is the last program that I was able to get to compile... I am supposed to remove the user input section, but no matter what I try, it doesn't work....

[Program removed as per site rules - see FAQ]

Pleeeease java geniuses... HELP!!! :)
I can be reached at <email removed>
Nov 29 '06 #1
109 25816
r035198x
13,262 MVP
Let's go one stage at a time then

[Program removed as per site rules - see FAQ]
Nov 29 '06 #2
horace1
1,510 Recognized Expert Top Contributor
your print statements in main() are a mixture of C++ and Java, i.e. to print to the screen in Java you use System.out.prin tln() not System.out.prin tf()
main() should look like
Expand|Select|Wrap|Line Numbers
  1. public class Inventory
  2. {
  3.    // main methods begins execution of java application
  4.    public static void main( String args[])
  5.    {
  6.          Supplies mySupplies = new Supplies();
  7.  
  8.          System.out.println("\n\nItem Name: "+mySupplies.getItemName()); //display item name
  9.                  System.out.println("Item Number: "+mySupplies.getItemNumber()); //display item number
  10.                  System.out.println("Quantity in Stock: "+mySupplies.getStockQuantity()); //display quantity in stock
  11.                  System.out.println("Item Price:$ "+mySupplies.getItemPrice()); //display item price
  12.                  System.out.println("Value of Inventory:$ "+mySupplies.calculateInventoryValue()); //display total value of inventory for this item
  13.  
  14.          System.out.println("\n\nEnter item name or enter the word stop to quit:");//prompt
  15.               //   mySupplies.setItemName(input.next()); // read item name or stop
  16.  
  17.  
  18.    } // end main method
  19. }//end class Inventory
  20.  
when run it gives
Item Name:
Item Number: 0.0
Quantity in Stock: 0.0
Item Price:$ 0.0
Value of Inventory:$ 0.0


Enter item name or enter the word stop to quit:

you now need to call setItemName(), setItemNumber() , etc to set up data in mySupplies
Nov 29 '06 #3
zaidalin79
59 New Member
yes please and thank you... you are a life saver!!
Nov 29 '06 #4
zaidalin79
59 New Member
Let's go one stage at a time then

[Program removed as per site rules - see FAQ]
This one worked beautifully... I guess I was sort of close... Thank you so much... what is the next step...?
Nov 29 '06 #5
r035198x
13,262 MVP
your print statements in main() are a mixture of C++ and Java, i.e. to print to the screen in Java you use System.out.prin tln() not System.out.prin tf()

[code removed as per site rules - see FAQ]

you now need to call setItemName(), setItemNumber() , etc to set up data in mySupplies
printf is now available in java 1.5
Nov 29 '06 #6
r035198x
13,262 MVP
This one worked beautifully... I guess I was sort of close... Thank you so much... what is the next step...?
Being close is the reason why it was easy to help you. Now have a look at this and make additions so that we can sort by name and test that functionality

[Code removed as per site rules - see FAQ]
Nov 29 '06 #7
zaidalin79
59 New Member
Where can I add the %.2f to get the currency to diplay two decimals?
Nov 29 '06 #8
r035198x
13,262 MVP
Where can I add the %.2f to get the currency to diplay two decimals?
Change this line
Expand|Select|Wrap|Line Numbers
  1. System.out.println("Total Value is"+s.getTotalValue());
  2.  
to make it use printf instead of println.
Nov 29 '06 #9
r035198x
13,262 MVP
Change this line
Expand|Select|Wrap|Line Numbers
  1. System.out.println("Total Value is"+s.getTotalValue());
  2.  
to make it use printf instead of println.
Remember Product is just a name I chose, you should change it to something that can be a superclass of some other object as per requirement in Part3
Nov 29 '06 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

12
2397
by: jason | last post by:
Access 2000: I have a customer-inventory table I need to loop through and compile a list of all the inventory items the customer is tracking. The problem I am finding is that a simple loop will pull out the customer details each time their is an inventory item listed....I need to get the customer out ONCE and list his items....is there an elegant way to do this: Here is the table: Cust-Invent Table
0
7113
by: south622 | last post by:
I'm taking a beginning Java course and I'm stuck in week eight of a nine week course. If anyone could help me I would greatly appreciate it. This assignment was due yesterday and each day I go past the due date 10% of the grade is taken off. I think I'm coming down with the flu and my brain is just not processing this assignment. Here is the assignment: Modify the Inventory program by adding a button to the GUI that allows the user to move...
67
23013
by: hollywoood | last post by:
I am trying to add the Delete button, save and search buttons. I have tried to call my teacher and he is absolutly no help and i have read and reread the text but still have no idea what is going on.........I have the added the add button but now i am stuck. Is there a simple way in completeing this?? Please help • Due Date: Day 7 forum • Modify the Inventory Program to include an Add button, a Delete button, and a Modify button on the...
4
1865
by: momov4 | last post by:
I can't seem to resolve these errors. I have had people compile these codes on their computers with no problem, but I keep getting errors...can anyone help???? Here are the errors: cannot find symbol method setItemNumber(java.lang.String) cannot find symbol method setProductName(java.lang.String) cannot find symbol method setNumOfUnitsInStock(int) cannot find symbol method getItemNumber() cannot find symbol method getProductName()...
4
2309
nexcompac
by: nexcompac | last post by:
Ok, I posted a similar post but now need to jump back into it. Here is what I have been able to clean up. I am using textpad and jbuilder. Still getting used to the whole java world and I am trying to compile a program using TextPad. Here is what I have so far. /* * Main.java * * Created on July 19, 2007, 5:54 PM *
3
6996
by: cblank | last post by:
I need some help if someone could help me. I know everyone is asking for help in java. But for some reason I'm the same as everyone else when it comes to programming in java. I have an inventory program that I have built so far with no problem. But I cannot figure out how to turn it into a GUI application. This is what I'm trying to get it to do. Modify the Inventory Program to use a GUI. The GUI should display the information one product...
2
2529
by: pinkf24 | last post by:
I cannot figure out how to add the following: Modify the Inventory Program to include an Add button, a Delete button, and a Modify button on the GUI. These buttons should allow the user to perform the corresponding actions on the item name, the number of units in stock, and the price of each unit. An item added to the inventory should have an item number one more than the previous last item. Add a Save button to the GUI that saves the...
1
2658
by: jcato77 | last post by:
I need help with a class project I'm working on, Below is my assignment and the code I have currently created. Assignment: Modify the Inventory Program by creating a subclass of the product class that uses one additional unique feature of the product you chose (for the DVDs subclass, you could use movie title, for example). In the subclass, create a method to calculate the value of the inventory of a product with the same name as the method...
13
2077
by: jcato77 | last post by:
I am having trouble figuring out my code and was hoping someone could point me in the right direction. Below is my code what I need to due is create a method to add and display the value of the entire inventory. I have what I think is the correct code but it's not working. Help is greatly appreciated class Inventory3 { public static final int MAXIMUM_ITEMS = 4; private static Product product = new Product; public static void...
0
8694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8621
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8890
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7757
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4634
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2355
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.