Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hey guys i have a question on how to solve this java question using methods. a report that is written to a file. Program Development

Hey guys i have a question on how to solve this java question using methods.

a report that is written to a file.

Program Development

  • You must break your program into a minimum of 3 methods, including the main. Each method should accomplish a specific task and be appropriately named.
  • I recommend writing the program without the file output to start. Once you get that part working, then print it to the file instead of the console.

Creating Formulas

Each line of the file will contain a number of elements each separated by a space. These elements are guaranteed to be grouped when there are several of the same element. You need to count the number of grouped elements by counting the number of occurrences of that element and then include that count after the element in the formula, except when there is only one.

For example:

H H O O

should become H2O2 because there are two H's followed by two O's.

and

K H C C C C H H H H O O O O O O

should become KHC4H4O6 combining the C's H's and O's

Naming the Compound

After you construct the formula for a given line in the log, you should then determine if the common name of that compound is known or unknown. Your program only knows the following six compounds:

  • NaHCO3 is Baking Soda
  • H2O2 is Liquid Bleach
  • KHC4H4O6 is Cream of Tartar
  • N2O is Laughing Gas
  • NaCl is Salt
  • C12H22O11 is Sugar
  • All other compound formulas are unknown

Your program should compare the formula you created to these known compounds, printing the compound name if known and "UNKNOWN FORMULA" followed by the formula if the compound is unknown.

Writing the summary to a file

As you analyze each line, you should print a summary to a new file called report.txt using a PrintStream. The summary should include the name of the compound (if known) or UNKNOWN FORMULA followed by the formula created for that entry (if unknown).

The file should also include a total count of formulas processed, as well as the count of the total and the percentage of unknown formulas.

sample

http://prntscr.com/mqmhb1

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

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

Assess three steps in the selection process.

Answered: 1 week ago

Question

Identify the steps in job analysis.

Answered: 1 week ago