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.
Now I seem to be getting 18 errors. Which sucks. Here are the errors.
Here are the errors in more detail.
Any help would be welcome :confused:
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.
Code:
/* * 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.
Code:
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
Comment