Results 1 to 3 of 3
Thread: GUI First Assignment-DUE 8/1/08
- 08-01-2008, 01:32 AM #1
Member
- Join Date
- Jul 2008
- Posts
- 43
- Rep Power
- 0
GUI First Assignment-DUE 8/1/08
This is my first GUI assignement which I have included the instructions below. I am having trouble starting this assignment. I am an online student and I usually have to wait 24 hours or longer for the teacher to respond to my questions. Therefore, I am hoping someong can point me in the right direction. These are the things I am confused on: Where do I include the GUI info in my program?, Do I have to make changes to the existing code?, Are the GUI pieces to be part of the main class?, or Are the GUI pieces suppose to be a classe of there own? I will be eternally grateful to anyone who can answer these questions for me. I have also submitted my existing program.
Assignment Instructions:
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.
Java Code:// CheckPoint: InventoryProgramPart3.java // Week 6 // This program calculates inventory value import java.util.Scanner; import java.util.Arrays; public class InventoryProgramPart3 { // main method begins program execution public static void main(String args[] ) { // create Scanner to obtain input from command window Scanner input = new Scanner( System.in ); // display a welcome message to the InventoryProgramPart3 user System.out.println( "Welcome to Inventory Program Part 3!" ); // office supplies supplies[] supplies = new supplies[100]; // an array of 100 supplies manufacturer[] manufacturer = new manufacturer[100]; manufacturer notepads = new manufacturer ( 4000, "notepads", 60, 2.75, "Ampad" ); manufacturer pencils = new manufacturer ( 5000, "pencils", 75, 1.25, "Bic" ); manufacturer folders = new manufacturer ( 2000, "folders", 30, 4.75, "3M" ); manufacturer envelopes = new manufacturer ( 1000, "envelopes", 15, 5.25, "Universal" ); manufacturer markers = new manufacturer ( 3000, "markers", 45, 3.50, "Sanford" ); // display the inventories one at a time envelopes.showInventory(); folders.showInventory(); markers.showInventory(); notepads.showInventory(); pencils.showInventory(); // sort supplies by name for ( int i = 0; i < args.length; i++ ) System.out.println( args[i] + ", " ); double array[] = { 82.69, 149.63, 165.38, 173.25, 98.44 }; double total = 0; // add each element's value to total for ( int counter = 0; counter < array.length; counter++) total += array[ counter ]; System.out.printf( "\nTotal inventory value is: $%.2f\n", total ); System.out.println( "\nThank you for using Inventory Program Part 3!\n" ); } // end method main } // end class InventoryProgramPart3 // Office Supplies class supplies { public int suppliesNumber; public String suppliesName = new String(); public int suppliesUnits; public double suppliesPrice; // set supplies number public void setSuppliesNumber( int number ) { this.suppliesNumber = number; } // end method set supplies number // return supplies number public int getSuppliesNumber() { return suppliesNumber; } // end method get supplies number // set supplies name public void setSuppliesName( String name ) { this.suppliesName = name; } // end method set supplies name // return supplies name public String getSuppliesName() { return suppliesName; } // end method get supplies name // set supplies in stock public void setSuppliesUnits( int units ) { this.suppliesUnits = units; } // end method set supplies units // return supplies units public int getSuppliesUnits() { return suppliesUnits; } // end method get supplies units // set supplies price public void setSuppliesPrice( double price ) { this.suppliesPrice = price; } // end method set supplies price // return supplies price public double getSuppliesPrice() { return suppliesPrice; } // end method get supplies price // calculate supplies inventory value public double getValue() { return suppliesUnits * suppliesPrice; } // end method supplies inventory value // four-argument constructor supplies( int number, String name, int units, double price ) { suppliesNumber = number; suppliesName = name; suppliesUnits = units; suppliesPrice = price; } // end four-argument constructor // display inventory public void showInventory() { System.out.println(); // outputs blank line System.out.println( "Product Number: "+suppliesNumber ); System.out.println( "Product Name: "+suppliesName ); System.out.println( "Units in Stock: "+suppliesUnits ); System.out.printf( "Unit Price: $%.2f", suppliesPrice ); // value() method and display the value System.out.printf( "\nInventory value of "+suppliesName+ " is = $%.2f\n", getValue() ); } // end display inventory } // end class supplies class manufacturer extends supplies { // holds the supplies manufacturer private String suppliesManufacturer; // five-argument constructor public manufacturer( int number, String name, int units, double price, String manufacturer ) { super( number, name, units, price ); // validate and store supplies manufacturer setSuppliesManufacturer( manufacturer ); } // end five-argument constructor // set supplies manufacturer public void setSuppliesManufacturer( String manufacturer ) { this.suppliesManufacturer = manufacturer; } // end method set supplies manufacturer // return supplies manufacturer public String getSuppliesManufacturer() { return suppliesManufacturer; } // end method get supplies manufacturer // calculate restocking fee public double getRestockingFee() { return super.getValue() * 0.05; } //end method calculate restocking fee //return String representation of suppliesManufacturer public String toString() { String formatString = "Manufacturer: %s"; formatString += "\nRestocking Fee: $%.2f\n"; formatString = String.format( formatString, suppliesManufacturer, super.getValue() * 0.05 ); return( formatString ); } // end toString() // display inventory public void showInventory() { super.showInventory(); System.out.println( toString() ); // Display value plus restocking fee System.out.printf( "\nTotal Inventory value of "+suppliesName+ " is = $%.2f\n", super.getValue() * 0.05 + super.getValue() ); } // end method display inventory } // end class manufacturer
- 08-01-2008, 03:00 AM #2
Do a search on this forum for JFrame. That should bring up plenty of coding examples. Most GUI programs use the JFrame class.
- 08-01-2008, 04:23 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
At least on Google. You can find a lots of such similar examples on the web. Seems to me this is the first time you are going to work with GUI, so you have start from the beginning. I don't think most of our members have enough time to do that for you. So make an attempt at least and post your any question if you stuck with.
Similar Threads
-
stuck on an assignment
By starchildren3317 in forum New To JavaReplies: 11Last Post: 11-19-2008, 11:03 PM -
First GUI Assignment
By ljk8950 in forum New To JavaReplies: 1Last Post: 07-31-2008, 07:29 AM -
Turtle assignment
By jmc724 in forum New To JavaReplies: 11Last Post: 07-16-2008, 09:11 PM -
for Assignment plz help
By assamhammad in forum New To JavaReplies: 1Last Post: 11-06-2007, 08:35 PM -
Help with my assignment java
By toby in forum New To JavaReplies: 1Last Post: 08-07-2007, 05:59 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks