473,287 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

I need to create a GUI for my Inventory Program

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_part1java;

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

import java.text.DecimalFormat; // program uses class DecimalFormat
import java.util.Scanner; // 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.print( "1 " ); // prompt
System.out.flush(); //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.print( "1 " ); //prompt
number = input.nextInt(); // read product number
}

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

System.out.print( "2 " ); // prompt
System.out.flush(); //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.out.print( "1 " ); // prompt
System.out.flush(); //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.print( "1 " ); //prompt
number = input.nextInt(); // read product number
}

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

System.out.print( "2 " ); // prompt
System.out.flush(); //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.print( "2 units " ); //prompt
units = input.nextInt(); // read product number of units
}

System.out.print( "$13.49" ); // prompt
System.out.flush(); //empties buffer before you input text.
price = input.nextDouble(); // read product price
while ( price < 0 ) //starts while loop to make sure a positive number is entered.
{
System.out.print( "$13.49 " ); //prompt
price = input.nextDouble(); // 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.println(product.toString() + " has inventory value = $" +
doubleFormat.format(product.inventory()) + "3");
}

}

package inventory_part3java;

// 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.DecimalFormat; // 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.println(subs[index].toString() + " Inventory Value: $" +
doubleFormat.format(subs[index].inventory()) + ".");
} // end loop to control number of products

// display the value of the entire inventory
System.out.println("\nEntire Inventory Value: $" + doubleFormat.format(entireInventory(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().compareToIgnoreCase(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 4440
Laharl
849 Expert 512MB
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 512MB
And don't forget to enclose your codes with codetag.

regards,
sukatoa
Apr 20 '08 #3
JosAH
11,448 Expert 8TB
@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
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...
12
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...
0
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...
38
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...
3
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...
1
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...
9
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...
5
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...
2
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.