Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objectives: Implement basic class concepts in Java Implement inheritance with super and sub-classes Implement basic polymorphism concepts Problem: The TARDIS has been infected by a

image text in transcribedimage text in transcribedimage text in transcribed

Objectives: Implement basic class concepts in Java Implement inheritance with super and sub-classes Implement basic polymorphism concepts Problem: The TARDIS has been infected by a virus which means it is up to Doctor Who to manually enter calculations into the TARDIS interface. The calculations necessary to make the TARDIS work properly involve real, imaginary and complex numbers. The Doctor has asked you to create a program that will evaluate numerical expressions so that he can quickly enter the information into the TARDIS. Details: Classes o Number class - Number.java Attributes Real number (double) Methods Default constructor Overloaded constructor - pass in value for number Accessor Mutator toString equals o Complex number class - Complex.java Extends number class (-5 points if not) Attributes: Imaginary number (double) Methods Default constructor Overloaded Constructor - pass in real and imaginary numbers o call super constructor Accessor Mutator toString equals Read in the entire expression as a string and parse it into the proper objects Store each part of the in the correct attribute of the object Use the toString function to display the number when necessary Both the real and imaginary parts may be floating point values Validate that each expression contains no invalid characters The only valid letter in a complex number is i (lower case) O Check that each expression contains a valid operator Each number in the expression must be stored in the appropriate object Real numbers are not to be stored in a complex object If a line contains invalid data, ignore the line Numbers may be represented in 3 ways o Complex (real + imaginary) . i o Real only . Imaginary only . i Numbers may be positive or negative Results for arithmetic operators will be numerical Results for relational operators will be Boolean Calculating less/greater than of a complex or imaginary number will be determined by analyzing the magnitude of each complex number All functions in Main.java that would normally require a real or complex number parameter object must use Object parameters instead (-10 points) o Use the instanceof operator to determine the type of object and perform the proper actions based on the object type User Interface: There will be no user interface for this program. All I/O will be performed with a files Input: Prompt the user for the name of the file containing the numerical expressions Each line in the file will contain an expression to be evaluated Valid line format: O can be real or complex Valid operators o +(add) o - (subtract) O * (multiply) o / (divide) o (greater than) O = (equal) There will be a newline at the end of each line except for the last line (which may or may not have a newline) Output: All output will be written to a file named results.txt. Output format: O Numerical values will be rounded to 2 decimal places. Relational operators will evaluate to true or false Each expression will be listed on separate lines Objectives: Implement basic class concepts in Java Implement inheritance with super and sub-classes Implement basic polymorphism concepts Problem: The TARDIS has been infected by a virus which means it is up to Doctor Who to manually enter calculations into the TARDIS interface. The calculations necessary to make the TARDIS work properly involve real, imaginary and complex numbers. The Doctor has asked you to create a program that will evaluate numerical expressions so that he can quickly enter the information into the TARDIS. Details: Classes o Number class - Number.java Attributes Real number (double) Methods Default constructor Overloaded constructor - pass in value for number Accessor Mutator toString equals o Complex number class - Complex.java Extends number class (-5 points if not) Attributes: Imaginary number (double) Methods Default constructor Overloaded Constructor - pass in real and imaginary numbers o call super constructor Accessor Mutator toString equals Read in the entire expression as a string and parse it into the proper objects Store each part of the in the correct attribute of the object Use the toString function to display the number when necessary Both the real and imaginary parts may be floating point values Validate that each expression contains no invalid characters The only valid letter in a complex number is i (lower case) O Check that each expression contains a valid operator Each number in the expression must be stored in the appropriate object Real numbers are not to be stored in a complex object If a line contains invalid data, ignore the line Numbers may be represented in 3 ways o Complex (real + imaginary) . i o Real only . Imaginary only . i Numbers may be positive or negative Results for arithmetic operators will be numerical Results for relational operators will be Boolean Calculating less/greater than of a complex or imaginary number will be determined by analyzing the magnitude of each complex number All functions in Main.java that would normally require a real or complex number parameter object must use Object parameters instead (-10 points) o Use the instanceof operator to determine the type of object and perform the proper actions based on the object type User Interface: There will be no user interface for this program. All I/O will be performed with a files Input: Prompt the user for the name of the file containing the numerical expressions Each line in the file will contain an expression to be evaluated Valid line format: O can be real or complex Valid operators o +(add) o - (subtract) O * (multiply) o / (divide) o (greater than) O = (equal) There will be a newline at the end of each line except for the last line (which may or may not have a newline) Output: All output will be written to a file named results.txt. Output format: O Numerical values will be rounded to 2 decimal places. Relational operators will evaluate to true or false Each expression will be listed on separate lines

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

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions