• Post Reply Bookmark Topic Watch Topic
  • New Topic

Order Form Program  RSS feed

 
Mike Mo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the directions given for this assignment were: The local Candy Store ships candy around the world. 12 candy bars fit into each carton when they package it. They provide a discount for the number of cartons ordered. You are to write the class needed to calculate how much is owed. The handout has the UML and description for the classes that you are to write.

Due Feb 7th, 11:55PM

No Late assignments will be accepted.

If the program doesn't compile it will be a zero


I have started this assignment and i hope im doing it right. im trying to keep lines shorter and not cram too much shit into my main method (havent made it yet). this is waht i have so far. im confused on how i am supposed to do the discount. i tried to set up and if else statement but im not sure how to get it to save the discount applied and then be able to call it from a method to have it print a total after discount on the reciept.



it wont let me upload a pdf to show what the program is supposed to do. professor calls it a UML. like my outline for the program.
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try attaching the PDF (tab below the text box) rather than using an img tag.
 
Mike Mo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UML

Programming Assignment 1
Due: Tuesday February 7, 11:55PM – Late assignments will not be accepted
50 Points Part 1 – Create the class described below.
Constructors
Customer
-customerLastName: string 
-candyType: string
-numCandyBars: int
-costPerBar:double
-NUMBERPERCASE: final int = 12
+Customer()
+Customer(name:String, type:String,
numCandyBars:int, costPerBar:double)

+getCostPerBar():double
+getNumCandyBars():int
+getCandyType():string
+getCustomerLastName():string

+setCustomerLastName(name:string):void
+setNumCandyBars(num:int) :void
+setCandyType(candyType:string):void
+setCostPerBar(cost:double) :void

+computeNumCases():int
+computeNumIndividuals():int
+computeDiscount():int
+computeCost():double

+printReceipt():void

There are two constructors – the one with no formal parameters has nothing in the method body. The one with formal parameters assigns the values passed in to the class instance variables

Mutators
Sets the appropriate fields (instance
variables) to the values passed in

Accessors
Returns the appropriate field 

computeNumCases returns how many cases there are

computeNumIndividuals returns how many candy bars don’t fit in the cases

computeDiscount
returns the discount that will be applied. It calls the method to find out how many cases there are and then determines the discount based on the follow scale: 0 – 19 cases – 0% discount
20 – 49 cases – 15% discount
50 or more – 25% discount
computeCost returns the cost of all of the candy bars. you should call other methods in the class to help determine the cost. This is how the cost is computed:
- All candy bars in a case have the discount applied to them - All individual candy bars get no discount

printReceipt
Displays the receipt as show on the output.
1/2 Spring 2017
 
Part 2
Create another class to write the main method to drive the class. The main method should create objects of the class and produce the output shown below.
Note: Even though the main
Output #1 method doesn’t use all of the  methods in the class, all methods in
Programmed By <Put your name here>
 
Enter the first customer's last name: Tetzner
Enter the type of candy: M&Ms  
Enter the number of bars purchased: 150
Enter the cost of one M&Ms: .79
*************************************
               RECEIPT
Customer: Tetzner
Type of Candy: M&Ms
Cost per bar: $0.79 
Number of Cases: 12
Number of individuals: 6 
Total amount due: 118.50
*************************************
 

Enter the second customer's last name: Martin
Enter the type of candy: Butterfinger
Enter the number of bars purchased: 350
Enter the cost of one Butterfinger: 1.29
*************************************
                RECEIPT
Customer: Martin
Type of Candy: Butterfinger
Cost per bar: $1.29
 
Number of Cases: 29
Number of individuals: 2

Total amount due: $384.16
*************************************

 
Customer Comparison
Martin bought more candy bars
Martin spent more money 
the class should work properly. You
might want to test each method,
Output #2 before doing Part 2.
printReceipt prints this



Requirements
1. Your output should be identical (except for your name) to the output shown, this includes spacing. It should also run for any valid input given.
2. The following comments should be at the top of all files that you type
/*Name: XXXXXX XXXXXXXXX
* Class: CS140-XXX
* Spring 2017
* Assignment: Programming Assignment X
* Date: XX/XX/XXXX 
*/
3. Submit the zipped project folder to moodle by the due date (If you are not sure how, ask in class)
iue.edu
Words of Wisdom
1. Do NOT enter all of the program in at one time and then compile and run it. Get little parts to work, before adding more.
2. DO NOT WAIT UNTIL THE LAST MINUTE!!! Things come up with computers. Try to start assignments as soon as you get them.
2/2 Spring 2017
 
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow. So, the Customer class is supposed to have a constant called NUMBERPERCASE, huh. So does that mean you're going to be putting your customers into cases, a dozen of them per case? If not, why attach that constant to the Customer class? Ask your teacher that and see what she says.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In fact, ask why your Customer class has fields and methods that pertain to a specific Product that you're selling. This is a blatant violation of the Single Responsibility Principle.
 
Mike Mo
Ranch Hand
Posts: 40
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:In fact, ask why your Customer class has fields and methods that pertain to a specific Product that you're selling. This is a blatant violation of the Single Responsibility Principle.


in one of my post on here i mentioned that i hate learning "dumbed down" versions of things. so why would she have us learn a shitty way to do something just for the sole purpose of showing us how to use something just to later on say btw what i taught you was complete crap. -_- i feel like im wasting my time learning the wrong ways to do things simply bc its the easier way to teach 60+ ppl at once. every time i post code, people on here are amazed at some aspect of how crappy an assignment is =^/
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is indeed one of the frustrating things we see more and more here. I've been trying to get some educators to talk to me about this -- I've managed to get someone who has posted on these forums to start looking into doing something about it with me but on another front, I was pretty much told to F* off. Seems some educators don't like the idea of considering that they may not be doing such a good job for their students.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might try to see what your instructor says about those questions I told you to ask. There's a slim chance she'll surprise you and say, "You know, that's a good point. That is confusing..." and maybe consider changing the problem statement. By slim though, I mean "I'm not holding my breath" slim.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Mo wrote:...simply bc its the easier way to teach 60+ ppl at once.

I can't imagine that it would be easier to teach 60+ confused students... it's tough enough trying to help you figure things out, how much more if we have all your 60+ classmates out here, all of them as confused as you are?
 
Campbell Ritchie
Marshal
Posts: 56598
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:. . . There's a slim chance she'll surprise you and say, "You know, that's a good point. That is confusing..." . . .
That may not be permissible. It is probably a rule that assignments cannot be changed once they are issued. Otherwise somebody else will complain, “I had it working beautifully for the old specification, and I can't get it to work now,” and it will be impossible to disprove. That is another reason why I don't like overspecified assignments.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Junilu Lacar wrote:. . . There's a slim chance she'll surprise you and say, "You know, that's a good point. That is confusing..." . . .
That may not be permissible. It is probably a rule that assignments cannot be changed once they are issued. Otherwise somebody else will complain, “I had it working beautifully for the old specification, and I can't get it to work now,” and it will be impossible to disprove. That is another reason why I don't like overspecified assignments.

Not unlike what happens at some places in the real-world, really. "Hey, uhmm, I hate to tell you guys this but we found out those requirements were wrong... we have to make some changes otherwise the company will end up losing lots of money." -- Response: "But we're already done with development and everything! We're getting ready to deploy it tonight!"

Stuff happens, people should get used to these things.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Mike, your prof's initials wouldn't happen to be E.L., would they? A little "emotional" maybe?
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Mo wrote:in one of my post on here i mentioned that i hate learning "dumbed down" versions of things. so why would she have us learn a shitty way to do something just for the sole purpose of showing us how to use something just to later on say btw what i taught you was complete crap. -_- i feel like im wasting my time learning the wrong ways to do things simply bc its the easier way to teach 60+ ppl at once. every time i post code, people on here are amazed at some aspect of how crappy an assignment is =^/

It's hard working with a teacher you don't respect.  But if I can give you some advice learned from experience, learning to deal with people in authority over you is a very useful skill.  As a programmer in the workforce you may have a supervisor who is not the best at what they do.  You may need to gently and privately point out a problem, or you may have to just suck it up and deal with it.
 
Mike Mo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:
Mike Mo wrote:in one of my post on here i mentioned that i hate learning "dumbed down" versions of things. so why would she have us learn a shitty way to do something just for the sole purpose of showing us how to use something just to later on say btw what i taught you was complete crap. -_- i feel like im wasting my time learning the wrong ways to do things simply bc its the easier way to teach 60+ ppl at once. every time i post code, people on here are amazed at some aspect of how crappy an assignment is =^/

It's hard working with a teacher you don't respect.  But if I can give you some advice learned from experience, learning to deal with people in authority over you is a very useful skill.  As a programmer in the workforce you may have a supervisor who is not the best at what they do.  You may need to gently and privately point out a problem, or you may have to just suck it up and deal with it.


no disrespect to my professor at all. she can code way better than i can and im sure she knows her stuff. i just disagree with the way its taught.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's good to hear. It's not our intent to incite you to rebellion and open defiance. You can still look for an upside to all this and learn from it: sometimes you can learn as much from mistakes and bad examples as you can from good examples. You just have to recognize what you're looking at and realize why it's confusing you so much and making your life difficult.

Anyway, there were a number of problems in that code you posted. The first thing I was going to point out was that the computeDiscount() method you wrote was declared to return an int value but the discount that you're calculating inside of it is a double value. That's not going to work. Plus, you don't have any return statements in that method so it won't even compile. 

Your teacher did give you some good advice: "Do NOT enter all of the program in at one time and then compile and run it. Get little parts to work, before adding more."
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!