Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!

Kevin Quarles

Greenhorn
+ Follow
since Sep 07, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kevin Quarles

I apologize for wasting your time. I found what I did wrong, and it had nothing to do with the errors I spoke of above. The problem was in the other classes, and after sleeping on it, I immediately saw what I did wrong.
11 years ago
Hello,

I am getting the following error that I can not figure out, or do not have any idea where to begin. It compiles, but when I go to run it, I get this:
Car

null

null

null

null

null

Exception in thread "main" java.lang.NullPointerException
at Inventory.value(Inventory.java:28)
at Inventory.view(Inventory.java:37)
at Inventory6.<init>(Inventory6.java:35)
at Inventory6.main(Inventory6.java:180)


Here are the codes in question:



and:

11 years ago
Ok, Got rid of both. It still compiles, but as soon as I run it, all I get is the c: prompt. SUV2 does not compile at all.
11 years ago
Thank you for your patience. Do I get rid of it? If I do that, I have to get rid of import java.util.Scanner as well, right?
11 years ago
Now this is more like it!!! I finally figured out what I needed. Now, When I compile, the program compiles, however the SUV class does not compile with it, and when I go to run the program, it kicks me right back out to the c: prompt.

InventoryProgramPart3 class:


Car2 class:


And SUV2 class


Let me repeat for you, there are no errors showing up when I compile or run the program, I am just getting kicked out of it for some reason
11 years ago
Here is what I got. I have been over and over this....reading the textbook over and over again, and still nothing! I am about ready to throw my computer out the darn window! I can't believe I have wasted the whole weekend trying to figure this out!

InventoryProgramPart3.java:46: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
public static double calculateInventory(Car2[] cars) {
^
InventoryProgramPart3.java:21: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
Car2 cars[] = new Car2[5];
^
InventoryProgramPart3.java:21: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
Car2 cars[] = new Car2[5];
^
InventoryProgramPart3.java:25: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
cars[0] = new Car2(1, "Escape", 24, 44675.75);
^
InventoryProgramPart3.java:27: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
cars[1] = new Car2(2, "Vue", 20, 29457.99);
^
InventoryProgramPart3.java:29: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
cars[2] = new Car2(3, "F-150", 12, 45233.25);
^
InventoryProgramPart3.java:31: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
cars[3] = new Car2(4, "Aerostar", 6, 5000.00);
^
InventoryProgramPart3.java:33: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
cars[4] = new Car2(5, "Caravan", 15, 24766.50);
^
InventoryProgramPart3.java:51: inconvertible types
found : <nulltype>
required: double
sum += cars[i].getUnitPrice();
^
9 errors

InventoryProgramPart3 class:



Car2 class:



SUV2 code:
11 years ago


Now I am only down to 9 errors. It seems like I am going around is circles. The last couple of errors are something that I have no idea what is wrong.
11 years ago
Ok, after some sleep last night, I made a few changes. Some of which were stupid mistakes on my part, and some of which I would have never found on my own. The first problem was the "MPG" in my SUV2 class. Another is that I found out that I was not using an array at all in the InventoryProgramPart3 class. Now I am getting 14 errors. I am wondering if I even did that array right. Am I on the right track to assume that all my problems are within the Car array?

Here is the code for InventoryProgramPart3:

11 years ago
Not insulted. But Frustrated...yes. Most of the mistakes I have made in the past ave been absolutely dumb. This one though takes the cake, if only I could figure out what I am doing wrong. Adding another class with the MPG requirement is throwing me off big time.

Thank you in advance. I can take any help I can get at this point.
11 years ago
Ok, I spent the day rewriting the whole thing and I think I made things worse.

Here are the errors when trying to compile the program:

InventoryProgramPart3.java:33: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
public static double calculateInventory(Car2[] cars) {
^
InventoryProgramPart3.java:8: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
Car2 cars[] = new Car2[5];
^
InventoryProgramPart3.java:8: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
Car2 cars[] = new Car2[5];
^
InventoryProgramPart3.java:12: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
Car2 Escape = new Car2(1, "Escape", 24, 44675.75);
^
InventoryProgramPart3.java:12: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
Car2 Escape = new Car2(1, "Escape", 24, 44675.75);
^
InventoryProgramPart3.java:14: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
Car2 Vue = new Car2(2, "Vue", 20, 29457.99);
^
InventoryProgramPart3.java:14: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
Car2 Vue = new Car2(2, "Vue", 20, 29457.99);
^
InventoryProgramPart3.java:16: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
Car2 F150 = new Car2(3, "F-150", 12, 45233.25);
^
InventoryProgramPart3.java:16: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
Car2 F150 = new Car2(3, "F-150", 12, 45233.25);
^
InventoryProgramPart3.java:18: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
Car2 Aerostar = new Car2(4, "Aerostar", 6, 5000.00);
^
InventoryProgramPart3.java:18: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
Car2 Aerostar = new Car2(4, "Aerostar", 6, 5000.00);
^
InventoryProgramPart3.java:20: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
Car2 Caravan = new Car2(5, "Caravan", 15, 24766.50);
^
InventoryProgramPart3.java:20: cannot find symbol
symbol : class Car2
location: class InventoryProgramPart3
Car2 Caravan = new Car2(5, "Caravan", 15, 24766.50);
^
InventoryProgramPart3.java:38: inconvertible types
found : <nulltype>
required: double
sum += cars[i].getUnitPrice();
^
14 errors

And now for the codes:

First one is InventoryProgramPart3:


The second one is Car2



The last one is SUV2. On this one, I have to use SUV and the extender, and I have to show MPG's (miles per gallon) I think I may have screwed up here, but I have so many things going on here, I am not quite sure what to do.

11 years ago
Ok, I have made a few changes, but I am still getting the errors from before.

Inventory3.java:10: cannot find symbol
symbol : variable Car
location: class Inventory3
Car = new Car(1, "Escape", 3, 34714.99);
^
Inventory3.java:11: cannot find symbol
symbol : variable Car
location: class Inventory3
Car = new Car(2, "Taurus", 5, 24999.99);
^
Inventory3.java:12: cannot find symbol
symbol : variable Car
location: class Inventory3
Car = new Car(3, "Vue", 4, 32799.99);
^
Inventory3.java:15: cannot find symbol
symbol : class Inventory
location: class Inventory3
i = new Inventory(3);
^
Inventory3.java:16: cannot find symbol
symbol : variable p1
location: class Inventory3
i.add(p1, 0);
^
Inventory3.java:17: cannot find symbol
symbol : variable p2
location: class Inventory3
i.add(p2, 1);
^
Inventory3.java:18: cannot find symbol
symbol : variable p3
location: class Inventory3
i.add(p3, 2);
^
Inventory3.java:21: cannot find symbol
symbol : method sort()
location: class Inventory3
i.sort();
^
Inventory3.java:25: cannot find symbol
symbol : method get(int)
location: class Inventory3
System.out.println(i.get(k));
^
Inventory3.java:31: cannot find symbol
symbol : method totalValue()
location: class Inventory3
System.out.printf("Total value = $%.2f", i.totalValue());
^

What am I doing wrong? I have been on this again since 6am this morning
11 years ago

Henry Wong wrote:You seem to be missing a few classes...

Inventory3.java:5: cannot find symbol
symbol : class Inventory
location: class Inventory3
private static Inventory i;
^
Inventory3.java:10: cannot find symbol
symbol : class SuvCar
location: class Inventory3
Suvcar = new SuvCar(1, "Escape", 3, 34714.99);
^



Where is the Inventory class, and the SuvCar class?

Henry



The 4 files I have are Inventory3, Car, Suv, and MPG. Is there any way to simplify this? I tried to play around with the classes in the Inventory3 part of it, but I am just getting more confused
11 years ago
Should both of them be named Car and Suv respectively?
11 years ago
Here is what I am supposed to have:

Modify the Inventory Program by creating a subclass of the product class that uses one additional unique feature of the product. This subclass must be "SUV" In the subclass, create a method to calculate the value of the inventory of a product with the same name as the method previously created for the product class. The subclass method should also add a 5% restocking fee to the value of the inventory of that product.
Modify the output to display this additional feature you have chosen and the restocking fee. The subclass of your product will be SUVs. This means that your subclass must be called “SUV”, and it will extend your “Car” class. The additional feature will be “mpg” which stands for the Miles Per Gallon. This data member should be of type “double” or “float”. The rest of the program will function the way it is described in the syllabus.

I get the following errors:

Inventory3.java:5: cannot find symbol
symbol : class Inventory
location: class Inventory3
private static Inventory i;
^
Inventory3.java:10: cannot find symbol
symbol : variable Suvcar
location: class Inventory3
Suvcar = new SuvCar(1, "Escape", 3, 34714.99);
^
Inventory3.java:10: cannot find symbol
symbol : class SuvCar
location: class Inventory3
Suvcar = new SuvCar(1, "Escape", 3, 34714.99);
^
Inventory3.java:11: cannot find symbol
symbol : variable Suvcar
location: class Inventory3
Suvcar = new SuvCar(2, "Taurus", 5, 24999.99);
^
Inventory3.java:11: cannot find symbol
symbol : class SuvCar
location: class Inventory3
Suvcar = new SuvCar(2, "Taurus", 5, 24999.99);
^
Inventory3.java:12: cannot find symbol
symbol : variable Suvcar
location: class Inventory3
Suvcar = new SuvCar(3, "Vue", 4, 32799.99);
^
Inventory3.java:12: cannot find symbol
symbol : class SuvCar
location: class Inventory3
Suvcar = new SuvCar(3, "Vue", 4, 32799.99);
^
Inventory3.java:15: cannot find symbol
symbol : class Inventory
location: class Inventory3
i = new Inventory(3);
^
Inventory3.java:16: cannot find symbol
symbol : variable p1
location: class Inventory3
i.add(p1, 0);
^
Inventory3.java:17: cannot find symbol
symbol : variable p2
location: class Inventory3
i.add(p2, 1);
^
Inventory3.java:18: cannot find symbol
symbol : variable p3
location: class Inventory3
i.add(p3, 2);
^
11 errors


Here is what I have come up with:

Inventory3:


Car class:


Suv class:


MPG class:

11 years ago