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
-
*
-
* To change this template, choose Tools | Template Manager
-
* and open the template in the editor.
-
*
-
*List item number, product name, quantity, price per unit, value of product, and total value of inventory.
-
*/
-
-
-
import java.util.Scanner;//program uses class Scanner
-
-
//ShowInventory program
-
public class ShowInventory
-
-
{ //main method begins execution of java application
-
public static void main (String args[])
-
{
-
Scanner myScanner = new Scanner (System.in);
-
-
//item name variable
-
String itemName1 = cd;//item name for inventory of music cd
-
String itemName2 = dvd;//item name for inventory of video media
-
String itemName3 = book;//item name for inventory of printed media
-
-
//item code variable
-
int code1 = 1000;//item code assigned to music cds
-
int code2 = 2000;//item code assigned to video media
-
int code3 = 3000;//item code assigned to printed media
-
-
//item quantity variable
-
int quantity1 = 15;//number of music cds on-hand
-
int quantity2 = 11;//number of video media on-hand
-
int quantity3 = 27;//number of printed media on-hand
-
-
//price of media variable
-
double price1 = 14.99;//assigned price of music cd
-
double price2 = 19.99;//assigned price of video media
-
double price3 = 12.99;//assigned price of printed media
-
-
-
//cd
-
-
class CD
-
{
-
private String name;
-
private int itemCode;
-
private int itemQuantity;
-
private double itemPrice;
-
-
//constructor to initialize the item with the information provided
-
public CD(String name, int itemCode, int itemQuantity, double itemPrice)
-
{
-
setName(name);
-
setItemCode(itemCode);
-
setItemQuantity(itemQuantity);
-
setItemPrice(itemPrice);
-
}
-
-
//get item name
-
public String getName()
-
{
-
return this.name;
-
}
-
-
//set item name
-
private void setName(String name)
-
{
-
this.name = name;
-
}
-
-
//set item code
-
private void setItemCode(int itemCode)
-
{
-
this.itemCode = itemCode;
-
}
-
-
//set item quantity
-
private void setItemQuantity(int itemQuantity)
-
{
-
this.itemQuantity = itemQuantity;
-
}
-
-
//set price of item
-
private void setItemPrice (double itemPrice)
-
{
-
this.itemPrice = itemPrice;
-
}
-
-
//calculate value of item on-hand
-
public double getItemValue()
-
{
-
return this.itemQuantity * this.itemPrice;
-
}
-
-
-
//DVD
-
class DVD
-
{
-
private String name;
-
private int itemCode;
-
private int itemQuantity;
-
private double itemPrice;
-
-
//constructor to initialize the item with the information provided
-
public DVD(String name, int itemCode, int itemQuantity, double itemPrice)
-
{
-
setName(name);
-
setItemCode(itemCode);
-
setItemQuantity(itemQuantity);
-
setItemPrice(itemPrice);
-
}
-
-
//get item name
-
public String getName()
-
{
-
return this.name;
-
}
-
-
//set item name
-
private void setName(String name)
-
{
-
this.name = name;
-
}
-
-
//set item code
-
private void setItemCode(int itemCode)
-
{
-
this.itemCode = itemCode;
-
}
-
-
//set item quantity
-
private void setItemQuantity(int itemQuantity)
-
{
-
this.itemQuantity = itemQuantity;
-
}
-
-
//set price of item
-
private void setItemPrice (double itemPrice)
-
{
-
this.itemPrice = itemPrice;
-
}
-
-
//calculate value of item on-hand
-
public double getItemValue()
-
{
-
return this.itemQuantity * this.itemPrice;
-
}
-
-
//book
-
class Book
-
{
-
private String name;
-
private int itemCode;
-
private int itemQuantity;
-
private double itemPrice;
-
-
//constructor to initialize the item with the information provided
-
public Book(String name, int itemCode, int itemQuantity, double itemPrice)
-
{
-
setName(name);
-
setItemCode(itemCode);
-
setItemQuantity(itemQuantity);
-
setItemPrice(itemPrice);
-
}
-
-
//get item name
-
public String getName()
-
{
-
return this.name;
-
}
-
-
//set item name
-
private void setName(String name)
-
{
-
this.name = name;
-
}
-
-
//set item code
-
private void setItemCode(int itemCode)
-
{
-
this.itemCode = itemCode;
-
}
-
-
//set item quantity
-
private void setItemQuantity(int itemQuantity)
-
{
-
this.itemQuantity = itemQuantity;
-
}
-
-
//set price of item
-
private void setItemPrice (double itemPrice)
-
{
-
this.itemPrice = itemPrice;
-
}
-
-
//calculate value of item on-hand
-
public double getItemValue()
-
{
-
return this.itemQuantity * this.itemPrice;
-
}
-
-
//calculate combined value of all inventory
-
double inventoryValue = cdItemPrice + dvdItemPrice + bookItemPrice;
-
-
-
-
//build array to house data
-
//InitInventory.java
-
public class InitInventory
-
-
//initializer list specifies the value for each element
-
{
-
String inventory[] = {CD, DVD, Book};
-
int itemcode [] = {1000, 2000, 3000};
-
int itemquantity [] = {15,11,27};
-
double itemprice [] = {14.99, 19.99, 12.99};
-
double itemvalue [] = {15*14.99, 11*19.99, 27*12.99};
-
-
System.out.printf("%s&s\n", "Index", "Value");//column headings
-
-
//output each array elements value
-
for (String counter = 0; counter < array.length; counter ++)
-
System.out.printf("%5d%8d\n", counter, array[counter]);
-
-
for (int counter = 0; counter < array.length; counter ++)
-
System.out.printf("%5d%8d\n", counter, array[counter]);
-
-
for (double counter = 0; counter < array.length; counter ++)
-
System.out.printf("%5d%8d\n", counter, array[counter]);
-
}//end class InitInventory
-
-
}//end main
-
-
-
}//end ShowInventory
-
-
Now I seem to be getting 18 errors. Which sucks. Here are the errors.
Here are the errors in more detail. -
C:\Users\Brian\Documents\ShowInventory.java:222: <identifier> expected
-
System.out.printf("%s&s\n", "Index", "Value");//column headings
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:222: illegal start of type
-
System.out.printf("%s&s\n", "Index", "Value");//column headings
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:225: illegal start of type
-
for (String counter = 0; counter < array.length; counter ++)
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:225: > expected
-
for (String counter = 0; counter < array.length; counter ++)
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:225: <identifier> expected
-
for (String counter = 0; counter < array.length; counter ++)
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:226: <identifier> expected
-
System.out.printf("%5d%8d\n", counter, array[counter]);
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:226: illegal start of type
-
System.out.printf("%5d%8d\n", counter, array[counter]);
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:228: illegal start of type
-
for (int counter = 0; counter < array.length; counter ++)
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:228: > expected
-
for (int counter = 0; counter < array.length; counter ++)
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:228: <identifier> expected
-
for (int counter = 0; counter < array.length; counter ++)
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:229: <identifier> expected
-
System.out.printf("%5d%8d\n", counter, array[counter]);
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:229: illegal start of type
-
System.out.printf("%5d%8d\n", counter, array[counter]);
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:231: illegal start of type
-
for (double counter = 0; counter < array.length; counter ++)
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:231: > expected
-
for (double counter = 0; counter < array.length; counter ++)
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:231: <identifier> expected
-
for (double counter = 0; counter < array.length; counter ++)
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:232: <identifier> expected
-
System.out.printf("%5d%8d\n", counter, array[counter]);
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:232: illegal start of type
-
System.out.printf("%5d%8d\n", counter, array[counter]);
-
^
-
C:\Users\Brian\Documents\ShowInventory.java:238: reached end of file while parsing
-
}//end ShowInventory
-
^
-
18 errors
-
-
Tool completed with exit code 1
-
Any help would be welcome :confused:
4 2312 JosAH 11,448
Recognized Expert MVP
Your curly brackets don't match, i.e. not every { has a matching }.
kind regards,
Jos
What is the best way to keep track and fix my brackets?
What is the best way to keep track and fix my brackets?
Indent your code well and use an editor that helps you to format your code nicely.
If your instructor has you use command line try using Notepad++, when you place your cursor over a curly brace it will red out the match.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: royaltiger |
last post by:
I am trying to copy the inventory database in Building Access Applications
by John L Viescas but when i try to run the database i get an error in the
orders form when i click on the allocate button "Unexpected Error":3251
operation is not supported for this type of object.The demo cd has two
databases, one is called inventory and the other just has the tables for the
design called inventory data. When you run inventory the database works...
|
by: zaidalin79 |
last post by:
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 forum
• Choose a product that lends itself to an inventory (for example, products at your
workplace, office supplies, music CDs, DVD...
|
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...
|
by: xxplod |
last post by:
I am suppose to 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...
|
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...
| |
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...
|
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...
|
by: 100grand |
last post by:
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...
|
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 offered.
//Modify the Inventory Program to use a GUI. The GUI should display the
//informationone...
|
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...
|
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,...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |