Call the accessor methods to get the data and print it

Assignment Help Basic Computer Science
Reference no: EM13984588

Programming Assignment #3

Creating a Class

As seen on TV: "The National Collector's Mint allows you to own a piece of history with their recreation proof of the $50 Gold Buffalo Coin, the purest gold coin ever produced by the U.S. Government.

Because of a shortage of gold blanks, the U.S. Government had to stop production on the $50 Gold Buffalo Coin, resulting in skyrocketing prices among the latest edition. However, the National Collector's Mint has now released its nonmonetary tribute proof of the famous coin. Clad in pure 24K gold, the $50 Gold Buffalo Tribute Proof comes with an individually numbered Certificate of Authenticity. Only $9.95! (Plus shipping and handling)"

If you listen closely, you learn that each coin contains 14 milligrams of pure gold! Is that a deal or what? Let's create a class to find out.

I. Your "GoldDigger" Class

Create a class with these instance variables:

• The name of the coin
• The current price of gold, per ounce
• The selling price of the coin
• The shipping and handling charges, per coin
• The sales tax rate
• The amount of gold in the coin, in milligrams

Your class will have a constructor to initialize the instance variables, accessor (i.e. "get") methods to return the values of the instance variables, and a mutator (i.e. "set") method that updates the price of an ounce of gold.

Your class will have 2 additional methods:

1. A method that computes and returns the number of coins one would have to purchase in order to own one full ounce of gold

2. A method that computes and returns the premium (the extra amount you would pay) when buying one ounce's worth of coins (total cost of the number of coins computed by the above method, including S & H and sales tax) versus buying an ounce of gold.

Sales tax must be paid on the entire order for the coins, including the S & H, but not when buying the gold outright.

II. The Test Class

Now create a test class (aka: "client code") that uses the class you created above. In the main method you will

1. create an object

2. call the accessor methods to get the data and print it

3. get and print the number of coins (method 1., above)

4. get and print the premium (method 2., above)

5. modify the price of an ounce of gold

6. get and print the updated price of gold

7. get and print the new premium

III. Additional Specifications

1. All numeric instance variables must be type double

2. All output is to be done in the test class. None of the GoldDigger class methods does any output

3. The test class must call the accessor methods to get the data stored in the instance variables, and must call separate methods to compute and return the number of coins and the premium

4. Make sure all output is neatly presented and clearly labeled

5. Do not be concerned with the number of decimal places printed - we will soon learn how to control that

Although your program must work for any valid data, use this data in the run you hand in:

Name of the coin: $50 Gold Buffalo

Price of gold, per ounce: 1242.30

Selling price of the coin: 9.95

Shipping and handling charges: 4.95

Sales tax rate: 7.5%

Amount of gold in the coin, in mg: 14.0

Updated price of gold: 1655.50

IV. What to Upload to Moodle

Upload a zip file containing both classes and the program output

V. Due Date: Thursday, February 25th

Use 28.35 as the number of grams per ounce. There are 1000 milligrams in a gram.

Reference no: EM13984588

Questions Cloud

What steps do governments take to increase vaccination rates : Public health information can be broadcast at a cost of $100. Public health information is a pure public good, in that many people can use the information simultaneously and preventing people from using the information is very difficult. What are the..
Identify the internal control principles and their applicati : Identify the internal control principles and their application to the cash receipts transactions of the Anita Theater.
Return of foreign direct investment : You are working for a company that is considering investing in a foreign country. Management has requested a report regarding the attractiveness of alternative countries based on a number of factors, such as the ease of doing business, the level of..
Discuss the concept of value : Discuss the concept of "value" as it relates to social, environmental, and economic inputs. How is value perceived differently from different stakeholders? When looking at sustainability, why is "value" important?
Call the accessor methods to get the data and print it : A method that computes and returns the premium (the extra amount you would pay) when buying one ounce's worth of coins (total cost of the number of coins computed by the above method, including S & H and sales tax) versus buying an ounce of gold.
Standing for free soil and free labor the republican party : Standing for "free soil" and "free labor," the Republican Party was able to appeal to northern farmers and native-born workers, but at the price of alienating many northern manufacturers. Is this True or False?
What is your potential topic of interest : Potential topic - What is your potential topic of interest for dissertation research?
Calculate the electric potential energy stored in the system : Calculate the electric potential energy stored in the system, by integrating the energy density u = ½∈DE2 over all space.
Define geographic concepts of cultural landscape : This exercise is designed to have each student conduct research, assess and summarize his or her research findings, and present it in PowerPoint format. This will be just like writing a research paper, except that the research findings will be pre..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Explain the difference between data and information

Give your own best definition of information, and explain the difference between data and information. Your response should be at least 200 words in length. You are required to use at least your textbook as source material for your response. All sour..

  Evaluate following integrals using simpson rule

Evaluate following integrals using simpson's rule and corrected simpson's rule (or richardson extrapolation in case the corrected simpson's is not applicable). In each case, use n = 2,4,8,16,32.

  Models in financial economics

The CAPM is one of the most thoroughly researched models in financial economics. When beta is estimated in practice, a variation of CAPM called the market model is often used. To derive the market model, we start with the CAPM:

  Create a very simple four function integer calculator

Create a very simple four function integer calculator with buttons for Add, Subtract, Multiply, and Divide, and with two text-type input fields. When the user enters two numbers and clicks one of the buttons, the answer is displayed where shown.

  The key advantages and disadvantages of placing

Compare and contrast the key advantages and disadvantages of placing the following system types on a DMZ: Directory services (i.e. Microsoft AD), Web server, FTP server, File server, printer, and Domain Controller.

  Confidentiality and integrity for transaction to secure

Make a list of at least 10 confidentiality, integrity, and availability requirements which should be met for transaction to be secure.

  Select appropriate variable

1. (TCOs 1-8) NOTE: YOU DO NOT have to compile/run this code in eclipse. You are writing the code here only. Write a class called point that has attributes and methods to model an (x,y) coordinate in a 2-D environment. Select appropriate variable(s..

  Describe how to use d

Suppose you have two nonempty stacks S and T and a deque D. Describe how to use D so that S stores all the elements of T below all of its original elements, with both sets of elements still in their original order.

  Determine the top three things that the head of it

Determine the top three things that the head of IT should be doing to improve the skills of the IT staff.

  Benefits of use-case modeling

Analyze the benefits of use-case modeling and isolate the most advantageous benefit to the firm you currently work or worked in the past and state why.Describe the biggest challenge to the successful use of use-case modeling and recommend how to over..

  Compute probability distribution and conditional probability

Write down solution this question in cryptographic. Assume encryption function is defined compute probability distribution and conditional probability distribution.

  What would be the output of the countdown routine

Recursion is a powerful technique that is often utilized for a variety or problems. Often, people think iteratively rather than recursively. However, when thinking computationally, as in computer language, recursive techniques are often utilized.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd