Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java 1 Barry Project 1: Earth Element Histogram Report 1 Task Write as program to produce a report of the first twenty elements from the

image text in transcribedimage text in transcribedimage text in transcribed

Java 1 Barry Project 1: Earth Element Histogram Report 1 Task Write as program to produce a report of the first twenty elements from the periodic table. The report will include some data output, but also shows the element's abundance with most abundant elements having longer lines) as a histogram. Create class-level final variables for things you might wish to adjust later, e.g., a String called HISTOGRAM_PLOT_CHAR that holds an asterisk (per the sample below). 2 Output # Sym Name Abundance ********************** ***************** ************* *********** 6 GUES DOWN 10 11 12 13 14 15 16 17 18 19 20 * TOZ H He Li B C N 0 F Ne Na Mg Al Si P S ci Ar K Hydrogen Helium Lithium Beryllium Boron Carbon Nitrogen Oxygen Fluorine Neon Sodium Magnesium Aluminum Silicon Phosphorus Sulfur Chlorine Argon Potassium Calcium ***************** ************************ ********************** ******* *********************** *********************** ************************ ***************** ********************** ********************* ******************** *********************** 3 Code Implementation Create a class called ElementReport. Write all methods within that class. Follow our Course Style Guide found in Canvas (reference section, the first module). There will be more code duplication that you might like; do not worry about this for now. 3.1 Call Hierarchy Create the following public static methods. Use this exact call hierarchy (i.e., second-tier methods must not call each other; that would be chaining, and we never want that): main printElement print Number printSymbol printName printAbundanceHistogram Pape 1 of 4 Java 1 Barry 3.2 Methods Name printElement Description Displays one line of the report Returns (none) Parameters Element atomic number, symbol, name, and atomic weight abundance rank Element atomic number print Number (none) printSymbol Pads (3) & displays the number Pads (3) & displays the symbol Pads (15) & displays the Element symbol (none) printName Element name (none) name printAbundance Histogram* Displays (25) the abundance Element abundance (none) histogram for the element * You will need to do some manipulation on the original data, since low ranks mean high abundance. For example, a rank of 1 should display 25 characters to show its abundance. To do this, subtract rank from 101 and divide the result by 4. Note: you do not need to guard against bad data coming in via parameters; in later work, you will, though. 3.3 What You May Use Constants (at class level), using the requested naming convention (see the Course Style Guide) Variables, using the requested naming convention (see the Course Style Guide) Variable assignment and expressions Definite loopsfor); note that each graph should require no more than two for statements Console output via System.out.print and System.out.println, escape character tabs ("\t"). String static methods: valueOf, e.g., String.valueof(3) yields the String "3". String instance methods: length, e.g., if myName is "Bil", myName.length() yields 4 String concatenation operator (+), e.g., "Smith" + ", " "Sam" yields "Sam Smith" Casting to convert from a floating point to an integer, e.g., (int)3.6 yields 3 3.4 What You May Not Use Indefinite loops (while) Selection control structures (if or its stand-ins like switch and the ternary operator) Arrays, lists, or other data structures, objects, libraries, or methods we have not covered Additional helper methods or return values from the specified methods Class-level (global) variables 4 Data Here is the information you will need for the elements the report will show. 1, H, Hydrogen, 10 11, Na, Sodium, 6 2. He, Helium, 72 12, Mg, Magnesium, 7 3, Li, Lithium, 33 13, Al, Aluminum, 3 4, Be, Beryllium, 48 14, Si, Silicon, 2 5, B, Boron, 37 15, P, Phosphorus, 11 6, C, Carbon, 17 16, S, Sulfur, 16 7, N, Nitrogen, 30 17, CI, Chlorine, 19 8,0, Oxygen, 1 18, Ar, Argon, 44 9, F, Fluorine, 13 19, K, Potassium, 8 10, Ne, Neon, 73 20, Ca, Calcium, 5 Page 2 of 4 Java 1 Barry 5 Extra Credit Create a class called Limits. In it, write a main method that uses definite loops to verify the following statement: For a loan of $10,000 at an annual interest rate of 3%, the limit of the total amount paid as the number of payments approaches infinity is $10,150.75 Output should start like this: # Pmts Total Paid 1 10 100 10300.0 10165.74 To accomplish this task, you will need several building blocks: The formula for calculating a loan payment amount is shown below. We would normally round to the nearest penny-you cannot make payments in fractional centsbut leave it at full precision instead r(PV) 1-(1 + r)" PE P = Payment PV = Present Value r=rate per period n = number of periods The formula for calculating the total amount paid: TP = P(n) Round this to the nearest penny before display A Java method that rounds to the nearest integer: Math.round(number) Note that there is no second parameter; you will need to get creative A Java method that raises a number to a power: Math.pow(number, exponent) Incrementing your loop variable logarithmically; we want to see the number of payments and the total of payments for 1 payment a year, 10 payments a year, etc., through 1,000,000,000 payments a year (10%). 6 Submitting Your Work Submit the .java file(s) from your project in a single submission; there is no need to send other files or zip up the folder. 7 Grading Matrix Area Points Class 5% Methods Definitions 35% Calls 25% Parameters 25% Documentation/style 10% Page 3 of 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions

Question

=+ What would it look like? Who should deliver it?

Answered: 1 week ago