473,372 Members | 894 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,372 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 4446
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.