Inventory Program - Taking Input For ArrayList

Feb 3, 2014

I am stumped on a coding project I am working on. I am making an inventory program with predefined values for the items. I am not sure how to iterate through my arrayList, and allow the user to input the "number sold."

I have made an arrayList and populated it using the add(), but I am not sure if it is working correctly. This is my inventoryItem class :

package inventory;
import java.text.DecimalFormat;
public class inventoryItm {
String itemName;
double unitPrice;
int numberSold;

[Code] .....

View Replies


ADVERTISEMENT

Inventory Program - Displaying Information (Input From Array)

Sep 13, 2014

I'm working a an assignment for my IT/215 class and I'm having a little trouble with my arrays. My code compiles just fine but when it comes to displaying the information I've input into my array it doesn't seem to want to and I'm not sure what I'm doing wrong here. On line 136 originally I had [DVDs [count] = count+1]] but it wouldn't compile. I then put line 136 to [ DVDs[count] = new Inventory();] and I think that's were my issue is but I'm not sure....

// Purpose:the purpose of this software is to display inputs as wells as the stocks and price of inputs.

class Inventory
{
private double ItemNumber; //to store Item number
private String ItemName; //to store Item name
private double UnitsInStock; //to store number of units in stock
private double UnitPrice; //to store Unit price
private double InventoryValue; //to store Inventory value
private double TotalInventory; //to store Total Inventory value

[Code] .....

View Replies View Related

Adding Sort And Total Inventory Methods In Inventory Class

Apr 30, 2014

for my assignment I am to only add the sort and total inventory methods in the inventory class. And not create an array in the inventory class at all. My inventory class should contain all the variables needed to use with the two new methods: sort and calculate total inventory.By not creating any array in the inventory class and not touching the variables at all.

What I have came up with is:

public class inventory
{
private int prodNumber; // product number
private String prodName; // product name
private int unitsTotal; // total units in stock
private double unitPrice; // price per unit
private double totalInventory; // amount of total inventory
// initialize four-argument constructor

[Code] ....

The error message I get is:

F:Java Programminginventory.java:62: error: cannot find symbol
return prodName.compareTo ( s. getprodName() );
^
symbol: method getprodName()
location: variable s of type inventory
1 error

View Replies View Related

Scanner Taking Input Twice

Oct 29, 2014

I have a small bug in my program. The user is asked what person(s) information they want to access but lets say they want captain they must enter "captain" twice. I think it will make more sense to you with the code. I have searched all over to see what is causing the bug but still have found no resolution. I even tried making two different scanners but that didn't work either.

I know the while loop (line 16) I am using is causing the bug because it works fine without that but then I cannot validate the input.

package myproject;
import java.util.Scanner;
public class Enterprise {
public static void main (String[]args){
String userInput;

[Code]......

View Replies View Related

Taking In User Input While Encapsulating

Oct 25, 2014

What I have so far are two classes, Movie class and MovieTestDrive class. I've to get the title, genre and ratings for movies and then put them into an array and call the playIt() method.

I would like to create a for loop to iterate three times for three instances of the Movie class but I don't know how to do it.

When I try to run the code, it won't work and I don't know if this is because I have Scanner running incorrectly whilst encapsulating my data. What I have so far:

class Movie {
// Create instance variables for the Movie class.
private String title;
private String genre;
private int rating;
// Use getters and setters to set and display the variables.

[Code] .....

View Replies View Related

Taking Object As Input - Instanceof Keyword Test

Feb 7, 2014

I am trying to test the instanceof keyword. To do this, I've made a method with a simple logical test like so:

Java Code:

Vehicle vehicle1 = new Vehicle();
public void Type(){
if (vehicle1 instanceof Vehicle) {
System.out.println("Type = Vehicle");
}
else if (vehicle1 instanceof Car) {
System.out.println("Type = Car");
}
else if (vehicle1 instanceof Truck) {
System.out.println("Type = Truck");
}
}
} mh_sh_highlight_all('java');

I wanted to try implementing it into the class definitions for Vehicle, then extend that to Car and Truck, but I'm not sure how to use this test in a general case.

The only way this method works is if I set the test to specifically accept a specific object as a parameter.

I want to test multiple objects, but I'm not really sure how else to do this without simply copy-pasting the logical test multiple times and changing the respective objects that are used as parameters.

View Replies View Related

Swing/AWT/SWT :: Taking Inputs Based On Previous User Input

Jun 7, 2014

I'm developing a Swing application for the first time. To test my application, I have currently hardcoded some text labels and fields in a JPanel, so that a user can enter input details for a maximum of 3 segments. But this limits the maximum number of segments to 3. However, the requirement is that when the user enters the number of segments (could be greater than 3 as well), corresponding number of input sets need to be taken.

Screenshot attached, with values entered.

Basically I want to know how I should go about taking the inputs from the user.

View Replies View Related

Simple If Statement Taking A String Input Doesn't Work

Jun 6, 2014

Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
if (input == "next") {
System.out.print("good Job!");
}
else {
System.out.println("Why ?");
}

//If I type in next it prints out "Why ?" instead of "Good Job!" - Why though ?

View Replies View Related

Inventory Program - CompareTo Not Working

Jul 16, 2014

My instructor gave me this code to use as my Array sort. I can not get this to work. I do not get any compile errors, the code just does not do anything.

Java Code:

package inventoryprogram4;
import java.util.Scanner;
public class Inventoryprogram4
{
static GUI mainGUI = new GUI();
static String outText = "";

[Code] .....

View Replies View Related

Inventory Program - Display Information To GUI

Feb 28, 2015

I am trying to create a GUI with already existing code. My assignment is: 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.

Where to start. The text book does not cover a GUI that displays this type of information rather it just displays graphics. I would like to create a separate class that holds the GUI information just to make everything flow better. I have provided my current code below:

Java Code:

// ProductTest.java
// by JakeB
public class ProductTest {
// main method begins
public static void main(String[] args) // begin main {
myGUI display = new myGUI();
display.setVisible(true);

[Code] .....

This is all I have for the GUI. I am at a total loss and I am behind 2 weeks now. I cannot move forward until I am able to get this done and the class ends next week.

View Replies View Related

Inventory Program - Add / Delete / Modify / Search And Save

Feb 15, 2015

The goal was to add a few buttons an add delete modify search and save. I feel like I have the entire need satisfied. I'm having a few symbol problems which I'm not quite sure how to fix.

My full code is:

import javax.swing.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.awt.event.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

[Code] ....

which is directing me towards Prodname on the far right of the if statement. I'm not sure what the problem is. I've double checked my spellings several time for each spot and I cant quite get it.

Everyone has told me but I am aware that I made some bad decisions with the variables being capitalized this was my first go at a program and my instructor didn't let me know that thats the normal way to do it.

View Replies View Related

Inventory Form Program - User Update Data In The Table

Apr 30, 2015

I'm getting ready to code a program that takes record of items loaned and return in a table. I want more than one user to access the program to be able to update the data in the table. For instance, if one user added 5 new items to the table, all other users would be able open the program to see a modified table with 5 new items. Was looking for some advice and was wondering if implementing a database would work best.

View Replies View Related

ArrayList - Get User Input And Sum Together

Jul 2, 2014

Goal is to get user input and sum together. I've tried it different ways. This is the one with the least amount of problems.

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: java.lang.Integer.parseInt

ArrayList<Integer> leftCU = new ArrayList<>(); {
System.out.println
("Please enter one at a time the number of CU's for each class that is left to complete. Enter Q when done.");
leftCU.add(in.nextInt());

[Code] .....

View Replies View Related

Create Program That Prompts Input And Creates File With That Input As Name

Jul 14, 2014

So I was going to try to create a program that prompts input and creates a file (That didn't exist before) with that input as name.Then, the program prompts inputs after stating questions such as 1 + 1, then if the user inputs an answer, put "Question # = Correct "or" Wrong.Code SO Far:

Java Code:

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
public class File_Read {
public File_Read() {//File_Read is the Interactive object

[code]....

So that it puts the Correct or Wrong into the file.

View Replies View Related

Modifying ArrayList From User Input Java

Apr 13, 2015

With my code the menu runs. But when the user has typed in the name of a fruit (to reserve it) I'd like it to say 'Reserved' when the user then presses 'V' (to go and view all fruit)I have read Oracle Java Collections Arraylist and from my understanding I either have to code using the get method or equals method but I'm not too sure how to (I did try though)

import java.util.ArrayList;
import java.util.Scanner;
public class FruitApril {
public static void main(String[] args) {

[code]...

View Replies View Related

Making Home Inventory

Jan 22, 2014

I'm going to make Dekstop Based Home Inventory, do you have a tutorial for it ?

View Replies View Related

Inventory Part 2 Portion And Getting Errors

Apr 30, 2014

for my assignment I am to only add the sort and total inventory methods in the inventory class. And not create an array in the inventory class at all. My inventory class should contain all the variables needed to use with the two new methods: sort and calculate total inventory.By not creating any array in the inventory class and not touching the variables at all.For the inventoryTest class, I only need to declare an array of the inventory class by making an instance of the inventory.

public class inventory
{

private int prodNumber; // product number
private String prodName; // product name
private int unitsTotal; // total units in stock
private double unitPrice; // price per unit
private double totalInventory; // amount of total inventory

[code]...

View Replies View Related

Inventory And InventoryItem Class - Cannot Find Symbol

Oct 13, 2014

I created a Test main method to test my Inventory and InventoryItem class to see if they are functioning properly. I am currently trying to read a text .dat file, but I keep getting "...cannot find symbol" for descripIn when I try to compile it.

import java.util.Scanner;
import java.util.ArrayList;
import java.io.IOException;
import java.io.File;

[Code].....

View Replies View Related

Display Inventory In Console - Retail Items

Apr 7, 2014

Why does it keep giving me the error saying that RetailItem[] inventory not found(from the parameter) if its stated above?

RetailItem[] inventory = {jacket, jeans, shirt};
//Display the inventory in the console
display(inventory)
//Process a series of RetailItem sales
processSales(inventory);

//Display the updated inventory of Retailitems
display(inventory);

[Code] .....

View Replies View Related

Getting NullPointer Exception Error In Simple ArrayList Program

Mar 21, 2015

I am creating a simple ArrayList program that would enable one to input their username to it using a scanner. However, i am getting this error: "Exception in thread "main" java.lang.NullPointerException

at home.Members.addUser(Members.java:16)
at home.Main.main(Main.java:14)"

Here is the code! :

Main.java class
Java Code: import java.util.Scanner;
public class Main {

[code]....

View Replies View Related

Taking Out Min And Max From Array

Apr 11, 2014

This piece of code is giving me the most trouble as I cannot convert the self defined class (Fraction) into int in order to store the elements in the variable (max). What is the best way to go about grabbing the next element and storing it in max and compare it to the previous to get the highest and lowest value?

System.out.println("Enter numerator / denominator");
frak[0] = new Fraction(keyb.nextInt(), keyb.nextInt());
frak[0] = max;
for (int i = 1; i < frak.length; i++){ // starting from array element 1
System.out.println("Enter numerator / denominator");
frak[i] = new Fraction(keyb.nextInt(), keyb.nextInt());
if (max > frak[i]){
}

View Replies View Related

Keeping Track Of Inventory For A Company - How To Update Variables

Feb 11, 2015

My program is supposed to be used to keep track of inventory for a company. The user is prompted with a menu that asks them which item they want to update and then gives them another menu that allows them to buy, sell, or change the price of the items. For this, I need to have the variable values to change (based on the input of the user), because they are initially set to specific numbers. How would I do this?

Here's the part of my code that is relevant to this question:

balance = 4000.00;
lampQuantity = 400;
lampPrice = 10;
chairQuantity = 250;
chairPrice = 20.00;
deskQuantity = 300;
deskPrice = 100.00;
  
System.out.println("Current Balance: $" + balance);
System.out.print("1. Lamps " + lampQuantity);
System.out.println(" at $" + lampPrice);
System.out.print("2. Chairs " + chairQuantity);
System.out.println(" at $" + chairPrice);

[Code] .....

View Replies View Related

Call To OS From App Taking 10 Mins On Certain PC

Jul 9, 2014

I have written a java app that's been working for a few years now and the client is very satisfied. However, a certain user has been experiencing a problem where the app runs fine BUT whenever it interacts with the OS (Win7 in this case), it takes ~10 mins to respond. Actions include, for example, exporting the currently displayed JTable to a CSV file or making an OS call to open up MS Word, etc.

I copied the users version of the app onto my platform (win 8.1) and tested it on winXP too with no problems which points towards an issue on the users particular PC. Furthermore, it used to run on the users PC fine until something (??) happened.

I've tried the following so far:-

1. looked at System restore to check anything new installed - nothing obvious
2. disabling anti virus - problem still occurs
3. monitoring JVM process time using Task Manager - little CPU time seems to be utilised (=> no loop etc)

I'll try :-

1. using JvisualVM - although I don't think this will show me what's going on with the OS
2. excluding the JVM and the app from all anti malware

Any app or something that shows interaction with the OS so I can trace what might be intercepting the call from my app to the OS?

View Replies View Related

Standalone Taking So Much Time Than Web Application

Oct 29, 2014

I am working on a web-application where i have a functionality which generates reports based on the data from DB. for small amount of data its working nice if the data is huge its taking more time. to avoid this problem i developed a standalone batch where i generated the jar file for the sources in web-application and made a call to the appropriate methods.

But my problem is if web-application takes 10 secs to generate the report but in the case of standalone its taking nearly 3-5 mins to generate the same report. i didn't do much of the changes in code just using the same code as web-application

I am using tomcat 6 application server to run the web-application for standalone using batch commands.....

View Replies View Related

Taking String And Printing Only The Digits?

Apr 26, 2015

This is the code that I have so far, It will only print out the digit if it is entered first..How to I get it to print out all digits? and I am getting an error that the c is not initialized

import java.util.*;
//Write a program that prompts the user for some text. Output only the digits in that text. Hint: Use a loop and the Character.isDigit method.
public class Q1
{

[Code].....

View Replies View Related

Anomaly While Using Scanner Class For Taking Inputs

Feb 1, 2015

There is a problem that I am facing while using the Scanner class for taking inputs from the user. Suppose if I need to take an integer and a String input from the user, and I take the integer input first then the place where the user has to input the String skips and the variable shows a "" nothing on printing it. Suppose in this code snippet

import java.util.Scanner;
public class Test
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number");
int n = sc.nextInt();
System.out.println("Enter a word");
String str = sc.nextLine();
System.out.println("Enter integer is " + n);
System.out.println("Entered statement is " + str);
}
}

The output is
Enter a number
13
Enter a word
Enter integer is 13
Entered statement is

I need to know why this happens and how should I avoid it. I've seen that taking the String input first solves the issue but while taking the input in a loop to populate a database the program only lets the user enter the first statement and the following statements are skipped.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved