S. Eckstrom

Greenhorn
+ Follow
since Mar 03, 2019
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
6
Given in last 30 days
6
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by S. Eckstrom

I am trying to finish this, but i keep getting a couple of errors. This is the instructions for the assignment.

(1) Extend the ItemToPurchase class per the following specifications:

   Private fields
   string itemDescription - Initialized in default constructor to "none"
   Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt)
   Public member methods
   setDescription() mutator & getDescription() accessor (2 pts)
   printItemCost() - Outputs the item name followed by the quantity, price, and subtotal
   printItemDescription() - Outputs the item name and description.

(2) Create two new files:

   ShoppingCart.java - Class definition
   ShoppingCartManager.java - Contains main() method

Build the ShoppingCart class with the following specifications. Note: Some can be method stubs (empty methods) initially, to be completed in later steps.

   Private fields

   String customerName - Initialized in default constructor to "none"

   String currentDate - Initialized in default constructor to "January 1, 2016"

   ArrayList cartItems

   Default constructor

   Parameterized constructor which takes the customer name and date as parameters (1 pt)

   Public member methods

   getCustomerName() accessor (1 pt)

   getDate() accessor (1 pt)

   addItem()
       Adds an item to cartItems array. Has parameter ItemToPurchase. Does not return anything.

   removeItem()
       Removes item from cartItems array. Has a string (an item's name) parameter. Does not return anything.
       If item name cannot be found, output this message: Item not found in cart. Nothing removed.

   modifyItem()
       Modifies an item's description, price, and/or quantity. Has parameter ItemToPurchase. Does not return anything.
       If item can be found (by name) in cart, check if parameter has default values for description, price, and quantity. If not, modify item in cart.
       If item cannot be found (by name) in cart, output this message: Item not found in cart. Nothing modified.

   getNumItemsInCart() (2 pts)
       Returns quantity of all items in cart. Has no parameters.

   getCostOfCart() (2 pts)
       Determines and returns the total cost of items in cart. Has no parameters.

   printTotal()
       Outputs total of objects in cart.
       If cart is empty, output this message: SHOPPING CART IS EMPTY

   printDescriptions()
       Outputs each item's description.


The 1st error I get is this: (Please see the attachments for images)Test that getCostOfCart() returns 9 (ShoppingCart)
Your output
getCostOfCart() incorrectly returned 3


The 2nd error I get seems to be a spacing error. (Images) I don't believe that it is though. I think it maybe something else causing the issue. But I can not figure it out.

Here is my code:







I hope i explained everything well enough. I apologize for any confusion.
14 hours ago
How would I fix this? I am getting a similar issue with another project.  Thank you for your help.
14 hours ago
Thank you all for the help and suggestions, unfortunately, I ran out of time. I work full time 60 hrs/week in the evenings. The only time I have to do my homework is on the weekends and a few hours Monday before I leave for work. I could not figure out the problem(s) before the assignment was due Tuesday. I only received credit for 9 out of 20 points on the auto grader, which resulted in a cruddy % points. I have no time to go back over any work, as the next assignments are due weekly and I have 2 other classes as well. Again THANK YOU ALL!, Steve
1 day ago
On lines 13, 16, & 21, Eclipse is giving me the following: quick fixable warning: The value of the local variable n is not used, I have changed the variable "n" to "i" as that is what is used. I still get the string errors.
1 week ago
I haven't closed anything that I'm aware of. It appears to be a formatting issue, causing a lack of spacing between lines. Although is highlights the lettering to like I'm missing spacing there too, but I am not.
1 week ago
Thank you Carey Brown. I deleted the SCNR lines as you said. but I still get the same errors on lines 9 and 49. This maybe something more stringent with ZyBooks than with an IDE. I'm not sure. I do know that all I get is this error in development and receive 9 points out of 20 for the assignment. I got a class @ 1:00pm then work @ 4:00. So I'll try until I go. Thank you for all your help. S. Eckstrom

Enter a sample text:Exception in thread "main" java.util.NoSuchElementException: No line found
   at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
   at AuthoringAssistant.inputString(AuthoringAssistant.java:49)
   at AuthoringAssistant.main(AuthoringAssistant.java:9)
1 week ago
Thank you for all your time Carey Brown. I have applied the changes, but obviously I have not done it correctly. Here is my code. I am assuming that the Scanner is not applied correctly. I'm about to give up. I work 60 hrs/week and this is due tomorrow. So no much time left. Thank you anyway for all your time and help.



1 week ago
Thank you for you suggestions. I have tried the scanner changes, but the ZyBooks can't seem to get past the "Scanner.nextLine" and String issue(lines 49 & 9, bottom of post under Development errors). I can re-post the code if needed, but the scnr is really all that has changed.

This is the result I get from submitting for grading (we can submit as many times as we need until due date/time). Please notice the errors included as output under the "MENU". It is different errors than the ones I get in development mode. I'll post that below. I hope this helps. I am lost on this.

2: Compare output

Output differs. See highlights below.

Input

We'll continue our quest in space.  There will be more shuttle flights and more shuttle crews and,  yes,  more volunteers, more civilians,  more teachers in space.  Nothing ends here;  our hopes and our journeys continue!


YOUR OUTPUT

Enter a sample text:You entered: We'll continue our quest in space.  There will be more shuttle flights and more shuttle crews and,  yes,  more volunteers, more civilians,  more teachers in space.  Nothing ends here;  our hopes and our journeys continue!

Enter your choice : Exception in thread "main" java.util.NoSuchElementException
at java.base/java.util.Scanner.throwFor(Scanner.java:937)
at java.base/java.util.Scanner.next(Scanner.java:1478)
at AuthoringAssistant.printMenu(AuthoringAssistant.java:74)
at AuthoringAssistant.main(AuthoringAssistant.java:12)


EXPECTED OUTPUT

Enter a sample text:

You entered: We'll continue our quest in space.  There will be more shuttle flights and more shuttle crews and,  yes,  more volunteers, more civilians,  more teachers in space.  Nothing ends here;  our hopes and our journeys continue!

Choose an option:


Here is the errors in Develop mode:

Enter a sample text:Exception in thread "main" java.util.NoSuchElementException: No line found
    at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
    at AuthoringAssistant.inputString(AuthoringAssistant.java:49)
    at AuthoringAssistant.main(AuthoringAssistant.java:9)
1 week ago
Thank you for the reply's. This will seem dumb to you guys but if I use the " private static final Scanner SCNR = new Scanner( System.in ); " how do I re-label my scnr's I had previously? (scnr2 and scnr3).
Also will this help me with the String errors I listed at the top of the forum?
1 week ago
I didn't get any with Eclipse either, but I'm new to all this Java stuff, so I may not be using Eclipse correctly. I am using 2 Scanners, how can I modify this to use just 1?
1 week ago
Hello, I am working on code for a class. I am a beginner and need some help. The assignment is 7 parts long and I keep getting an error right away. I'm thinking it is a simple fix, but I can't figure it out.
I've been doing research and am wondering about adding "hasNextLine()", but I don't know where. Thank you for you help.
Here is the error:

Enter a sample text:Exception in thread "main" java.util.NoSuchElementException: No line found
                                                                                                                      at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
                                                                                                                      at AuthoringAssistant.inputString(AuthoringAssistant.java:44)
                                                                                                                      at AuthoringAssistant.main(AuthoringAssistant.java:8)

Here is my code: ( I hope I am doing this correctly, as last time I was told I did not.)
1 week ago
Hello, I'm working on an assignment for my Java class. This is the basics of what the assignment is:
This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team.

I'm needing help to figure out why I keep getting this message:

Enter player 1's jersey number:
Enter player 1's rating:
Exception in thread "main" java.util.NoSuchElementException
at java.base/java.util.Scanner.throwFor(Scanner.java:937)
at java.base/java.util.Scanner.next(Scanner.java:1594)
at java.base/java.util.Scanner.nextInt(Scanner.java:2258)
at java.base/java.util.Scanner.nextInt(Scanner.java:2212)
at PlayerRoster.main(PlayerRoster.java:14)

I thank you now, for looking at my code and for any help you can provide.

Here is my code:

3 weeks ago