Welcome to TRiBot Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


  • Content count

  • Joined

  • Last visited

  • Feedback


Community Reputation

1 Neutral

About Eggs

  • Rank
    New Botter


  • Sex
  1. Hey there, I'd like to chime in on this (Entirely new to the website). I was/am the Computer Science tutor at my college and there are a few things that I used to break projects down for people. 1. The best thing to do is to always create an algorithm or structure chart of some type (Something like a UML but it can be totally sketched out/text based). Quick rundown of the program: Driver Class: Instantiates products with names/prices. It will then output a set of information to the console and ask for user input (With the scanner). Product Class: Receives the information from the driver class and "assigns it" Change Class: When called, you will pass through the total cost/tendered amount and it will do the calculations. Or you will pass through the total cost and the Change Class could manage the user input for the tendered amount. However, I would suggest keeping user input within the main method. Now that we have a bases of how the program should operate, we can begin to look at the code itself. This isn't something that I can just write for you, but something that I can help guide you in the right direction (Same thing that NewBotterFTW said). One thing I noticed in the code you posted above was that you were declaring the price of the product within the default constructor. It should actually be the name of the product as that is what the assignment description calls for. You are also missing the get/set total price and the getName methods for the Product class. Regarding the default constructor and how it should be the name instead of the price: public class Product { /*We must declare the variables outside of the default constructors/methods to be used within* the entire class.**Each time we create a new product object (Product socks = new Product("Socks"),* they will each have their own "unique" productName and itemPrice.** Remember:* Product socks = new Product("Socks");* Product boots= new Product("boots");** Although socks and boots are both Product objects, they are individually unique.* socks.getName() would return the productName of socks - "Socks"* boots.getName() would return the productName of booys - "boots"**/private double itemPrice; private String productName;public Product(String nm) { //Here, we must say this.productName instead of just productName.// This is because we must assign the string to the "global" variable productName instead of the local one (Look up scopes of variables).this.productName = nm; } }Once you have made this change, creating a "Product object" within the driver class is pretty easy. Product socks = new Product ("Socks");socks.setPrice ( 200 );Remember that for the assignment, it asks for everything in cents. So 200 = $2. You will have to complete a easy/simple math calculation in order to make your final output change it from cents to dollar format.