Liam Smith

Greenhorn
+ Follow
since Oct 23, 2012
Merit badge: grant badges
For More
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 Liam Smith

Stuart A. Burkett wrote:

Liam Smith wrote:

Stuart A. Burkett wrote: No it's not. Your code doesn't do what the specification says.



Can you clarify on this? When I run the program, input the at least 3 values and end the program. Linked list does return in reverse order which assignment asked for?


Assuming that it's lines 64 - 69 that supposedly do that, the code is inside the while loop so will print out every time round the loop, not just after the user has pressed something other than 'y'.

There's also a better method than listIterator to get the list in descending order. The highlighted word is to give you a clue.



Thank you for pointing out that I have put code inside while. I have recode, hopefully I got right this time.

11 years ago

fred rosenberger wrote:I would say it doesn't since it won't compile as written above:



That's odd, it compile fine on mine:

11 years ago

Stuart A. Burkett wrote: No it's not. Your code doesn't do what the specification says.



Can you clarify on this? When I run the program, input the at least 3 values and end the program. Linked list does return in reverse order which assignment asked for?
11 years ago
Assignment ask for:

Declare a variable at the beginning of the main method for a linked list that stores stings - completed

After the code that calculates, formats, and displays the result for each calculation, add code that formats a string with the results of the calculation and then stores the string in the linked list. - I completed the 2nd part (store string in the linked list) but I am at loss for first part. What does it mean by "add code that formats a string with the results of the calculation"?

Add code to display the elements in the linked list at the console when the user indicates that the program should end. This code should retrieve the elements of the linked list in reverse order. To do that, you'll need to use methods of the LinkedList class. Then, test the program by making at least 3 future value calculations. - completed

I am almost done with this assignment and only thing threw me off is 2nd question. What does it really mean?

Here's my code:

11 years ago
I am still struggling on this issue. Is there any link or information where I can look up more about how to call enum as argument in method?

Thanks!
11 years ago

Campbell Ritchie wrote:Welcome to the Ranch

That is not an Enumeration, but an enumerated type. Enumeration is an old legacy interface which you ought not to use in new code.
What you are doing is getting confused about what you can use for the switch‑case statement. You ought to be using the members of that enum, bvut you have managed to write it taking Strings. Change the set discount method parameter to take the customer type enum as an argument, and it should work better.
Various things could be tidied up:-

  • I don’t like the name of the set discount method. Maybe setDiscountFromCustomerType???
  • You are calling the getDiscount method twice, but only using its return value once.


  • Thank you for a warm welcome! Ok, good to know about Enumeration and enumerated type.

    I have tried to change set discount method parameter, and I am not sure how? I am getting errors.

    Thank you for other suggestions, I have applied the changes and as soon I figure out how to make set discount method to take enum, I will re-posted the code.
    11 years ago

    Winston Gutkowski wrote:

    Liam Smith wrote:I am having issue with the following code. I need to return the description from enumeration...


    1. Be careful when using the term "enumeration" to Java programmers - especially with a capital 'E' - because there is already a legacy class called Enumeration, and it's NOT the same as an enum.

    2. Seems to me that you could put your discounts in your enum, viz:and save yourself a pile of problems.

    HIH

    Winston



    Thank you for clearing up difference between enum and Enumeration.

    I would put discount in the enum, but unfortunately text call for method to be used in the main method not in enum.
    11 years ago
    I am having issue with the following code. I need to return the description from enumeration to the customerType.toString. Yet, when I declare the variable in the main app, then I will get error when I use cta.setDiscount(CustomerType);

    Am I missing something here? Here's my code.

    Main App


    Enumeration code

    11 years ago