473,583 Members | 2,878 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I need to create a GUI for my Inventory Program

1 New Member
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.

Here is my Inventory program from 1 to 3:
package inventory_part1 java;

// Inventory_Part1 .java
// Inventory_Part1 program reads user information for a product, display its properties and its inventory

import java.text.Decim alFormat; // program uses class DecimalFormat
import java.util.Scann er; // program uses class Scanner

public class InventoryPart1 {


public static void main(String[] args) {
// create a tool that insure the specified format for a double number, when displayed
DecimalFormat doubleFormat = new DecimalFormat( "0.00" );

// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );

int number; // stores the user DVD number
String name; // stores the user DVD name
int units; // stores the user DVDs number of units
double price; // stores the user DVD price

System.out.prin t( "1 " ); // prompt
System.out.flus h(); //empties buffer before you input text.
number = input.nextInt() ; // read product number
while ( number < 0 ) //starts while loop to make sure a positive number is entered.
{
System.out.prin t( "1 " ); //prompt
number = input.nextInt() ; // read product number
}

System.out.prin t( "Hustle and Flow. " ); // prompt
System.out.flus h(); //empties buffer before you input text.
input.nextLine( ); //prompt user for input
name = input.nextLine( ); // read product name

System.out.prin t( "2 " ); // prompt
System.out.flus h(); //empties buffer before you input text.
units = input.nextInt() ; // read product number of units
while ( units < 0 ) //starts while loop to make sure a positivSystem.o ut.print( "1 " ); // prompt
System.out.flus h(); //empties buffer before you input text.
number = input.nextInt() ; // read product number
while ( number < 0 ) //starts while loop to make sure a positive number is entered.
{
System.out.prin t( "1 " ); //prompt
number = input.nextInt() ; // read product number
}

System.out.prin t( "Hustle and Flow. " ); // prompt
System.out.flus h(); //empties buffer before you input text.
input.nextLine( ); //prompt user for input
name = input.nextLine( ); // read product name

System.out.prin t( "2 " ); // prompt
System.out.flus h(); //empties buffer before you input text.
units = input.nextInt() ; // read product number of units
while ( units < 0 ) //starts while loop to make sure a pose number is entered.
{
System.out.prin t( "2 units " ); //prompt
units = input.nextInt() ; // read product number of units
}

System.out.prin t( "$13.49" ); // prompt
System.out.flus h(); //empties buffer before you input text.
price = input.nextDoubl e(); // read product price
while ( price < 0 ) //starts while loop to make sure a positive number is entered.
{
System.out.prin t( "$13.49 " ); //prompt
price = input.nextDoubl e(); // read product price
}

// close the reading session
input.close();

// create a Product object with the user input
Product product = new Product(number, name, units, price);

// display the product's properties and its inventory

// display the product's properties and its inventory
System.out.prin tln(product.toS tring() + " has inventory value = $" +
doubleFormat.fo rmat(product.in ventory()) + "3");
}

}

package inventory_part3 java;

// Inventory_Part3 .java
// Inventory_Part3 creates an array of DVD products, ...
// displays the information and inventory for each product, sorted by title, and the entire inventory.
import java.text.Decim alFormat; // program uses class DecimalFormat
public class Inventory_Part3 {


public static void main(String[] args) {
// create a tool that insure the specified format for a double number, when displayed
DecimalFormat doubleFormat = new DecimalFormat( "0.00" );

// create an array of products with the specified length
Sub[] subs = new Sub[6];
subs[0] = new Sub(1, "DVD", 10, 10.99, "Hustle and Flow");
subs[1] = new Sub(2, "DVD", 12, 49.99, "The Best Man");
subs[2] = new Sub(3, "DVD", 30, 12.99, "Original Gangsters");
subs[3] = new Sub(4, "DVD", 16, 19.99, "Exit Wounds");
subs[4] = new Sub(5, "DVD", 19, 11.99, "Cradle to the Grave");
subs[5] = new Sub(6, "DVD", 18, 19.77, "Little Nicky");

// sort the array by name, calling the sortByName method
sortByName(subs );

// display the properties and the value of inventory for each product of the sorted array
// loop to control number of products
for (int index = 0; index < subs.length; index++)
{
System.out.prin tln(subs[index].toString() + " Inventory Value: $" +
doubleFormat.fo rmat(subs[index].inventory()) + ".");
} // end loop to control number of products

// display the value of the entire inventory
System.out.prin tln("\nEntire Inventory Value: $" + doubleFormat.fo rmat(entireInve ntory(subs)));

} // end method main

// sort an array of products send as parameter, by product's name, using Bubble Sort
public static void sortByName(Sub[] subs)
{
// loop to control number of passes
for ( int pass = 1; pass < subs.length; pass++ )
{
// loop to control number of comparisons
for ( int index = 0; index < subs.length - 1; index++ )
{
// compare side-by-side products and swap them if ...
// first product's name is greater than second product's name
if ( subs[index].getName().comp areToIgnoreCase (subs[index + 1].getName()) > 0)
swap( index, index + 1, subs );
} // end loop to control comparisons
} // end loop to control passes
} // end method sortByName

// swap two products specified by their indexes in the products array, send as well as a parameter
public static void swap(int first, int second, Product[] products)
{
Product hold; // temporary holding area for swap

hold = products[ first ];
products[ first ] = products[ second ];
products[ second ] = hold;
} // end method swap

// calculate the entire inventory for the array of products send as parameter
// make it static so that it can be called from the main method, which is static too
public static double entireInventory (Sub[] subs)
{
// a temporary double variable that the method will return
// after each product's inventory is added to it
double entireInventory = 0;
// loop to control number of products
for (int index = 0; index < subs.length; index++)
{
// add each inventory to the entire inventory
entireInventory = entireInventory + subs[index].inventory();
} // end loop to control number of products
return entireInventory ;
} // end method entireInventory

} // end class Inventory_Part3


I need help ASAP and be specific. Thanks
Apr 19 '08 #1
3 4467
Laharl
849 Recognized Expert Contributor
We're not going to do your homework for you. Go read a Swing tutorial (Google it) and try to do it yourself, then come back with specific problems.
Apr 19 '08 #2
sukatoa
539 Contributor
And don't forget to enclose your codes with codetag.

regards,
sukatoa
Apr 20 '08 #3
JosAH
11,448 Recognized Expert MVP
@100grrand: I hope you realize what you have just done: you've shown (part of)
your assignement text and asked for help. Help for what? You haven't done
anything (yet); do you want us to do *your* work while it's *your* assignment?

If so I consider that cheating.

kind regards,

Jos (moderator)
Apr 20 '08 #4

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

Similar topics

0
1397
by: shwekhaw | last post by:
Hi I have a retail website. I like to automate daily price file download and price update. Products listed on the site are shipped from four different distributors. So the final program will download price files from distributor website, read mapping file to determine which distributor file to read to update a particular product. Then...
12
2389
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...
0
7103
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...
38
4196
by: JenniferT | last post by:
OK, so I'm very new to Java programming and I've been able to squeek by so far, but I'm completely stuck on this assignment. Here is the assignment that is due this week - • 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,...
3
1677
MonolithTMA
by: MonolithTMA | last post by:
Greetings all, I am new here, and aside from my introductory post, this will be my first. I am working on an Inventory program for a class I am taking. I've searched the forums here and have seen other people working on the same or similar projects, but the problem I run into is that in Java, there seems to be more than one way to skin a...
1
2811
by: twin2003 | last post by:
need help with inventory part 5 here is what I have to do 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...
9
1959
by: Kiamari | last post by:
here's what i have to do: 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...
5
3369
by: cblank | last post by:
I'm having some trouble with my inventory program. Its due tom and my teacher is not wanting to help. He keeps giving me a soluction that is not related to my code. I have everything working except the Delete and Modify Button. The Search button works but it only searchs the new .dat file or what is set in the array. Not sure what is going on...
2
4430
by: blitz1989 | last post by:
Hello all, I'm new to this forum and Java and having a alot of problems understanding this language. I am working on an invetory program part 4. The assignment requirements are listed but the reading has very little in it that helps can someone take a look at this code and point me in the right direction please. Thanks for any help that is...
0
7888
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...
0
8314
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7922
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8185
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...
0
6571
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...
0
3811
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...
0
3836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.