Define a utility class for displaying values of type double. Call the class DoubleOut. Include all the methods from the class DollarFormat in Listing 6.14, all the methods from the class OutputFormat of Set-Test Question 30, and a method called scienceWrite that displays a value of type double using e notation, such as 2.13e-12. (This e notation is also called scientific notation, which explains the method name) When displayed in e notation, the number should appear with exactly one nonzero digit before the decimal point–unless the number is exactly zero. The method scienceWrite will not advance to the next line. Also add a method called scienceWriteln that is the same as scienceWrite except that it does advance to the next line. All but the last two method definitions can simply be copied from the text (or more easily from the source code for this book that is available on the Web.). Not that you will be overioading the method names write and writeln.
Write a driver
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Database Concepts (7th Edition)
Modern Database Management
Starting Out with C++ from Control Structures to Objects (8th Edition)
Starting Out with C++: Early Objects (9th Edition)
Starting out with Visual C# (4th Edition)
- #this is a python program #topic: OOP Design a class Joker with parameterized constructor so that the following line of code prints the result shown in the output box. [You are not allowed to change the code below] #Write your class code here j1 = Joker('Heath Ledger', 'Mind Game', False) print(j1.name) print(j1.power) print(j1.is_he_psycho) print(“=====================”) j2 = Joker('Joaquin Phoenix', 'Laughing out Loud', True) print(j2.name) print(j2.power) print(j2.is_he_psycho) print(“=====================”) if j1 == j2: print('same') else: print('different') j2.name = 'Heath Ledger' if j1.name == j2.name: print('same') else: print('different') #Write your code for 2,3 here Output: Heath Ledger Mind Game False ===================== Joaquin Phoenix Laughing out Loud True ===================== different same Subtask: 1) Design the class using a parameterized constructor. 2) The first if/else block prints the output as ‘different’, but why?…arrow_forward1) Through BlueJ, write if the current number of shoppers is greater than or equal to the number leaving then the number of shoppers is decreased by the number leaving. Otherwise, the following error message must be printed and the number of shoppers present must be set to 0. There is an error in the number of shoppers. Use System.out.println to print the message. 2) The class must define a method called leaving that takes a single integer parameter. This represents the number of shoppers leaving the club at a particular point. You may assume that the parameter's value will always be greater than zero and you do not have to check for that. If the current number of clubbers is greater than or equal to the number leaving then the number of clubbers is decreased by the number leaving. Otherwise, the following error message must be printed and the number of clubbers present must be set to 0. There is an error in the number of shoppers. Use System.out.println to print the error message. 3)…arrow_forwardToNearestPenny (amount)-a private static method that returns the given amount rounded to the nearest penny. For example, if the amount is 1023.659, the method will return 1023.66. 2. Consider a class Time that represents a time of day. It has attributes for the hour and minute. The hour value ranges from 0 to 23, where the range 0 to 11 represents a time before noon. The minute value ranges from 0 to 59. a. Write a default constructor that initializes the time to 0 hours, O minutes. b. Write a private method isValid (hour, minute) that returns true if the given hour and minute values are in the appropriate range. C. Write a method setTime (hour, minute) that sets the time if the given values are valid. d. Write another method setTime (hour, minute, iSAM) that sets the time if the given values are valid. The given hour should be in the range I to 12. The parameter isAm is true if the time is an a.m. time and false otherwise. 3. Write a default constructor and a second constructor for…arrow_forward
- Rewrite the normal rondull.arrow_forwardMethod Overloading is a feature that allows a class to have two or more methods having same name, if their argument lists are different. Argument lists could differ in: 1. Number of parameters. 2. Data type of parameters. 3. Sequence of Data type of parameters. Write different version of method sum() that display the sum of the values received as parameter according to the following main method content: public static void main(String[] args) { sum ( 10, 10 ); sum ( 10, 10, 10 ); sum ( 10.0, 10.0 ); sum ( 10, 10.0 ); sum ( 10.0, 10); } You have to define five functions with the specified types. Then, demonstrate the Argument Promotion concept by reducing the number of method to two.arrow_forwardGiven the starter code and instructions for 3 methods.How can I implement those 3 methods into the code?arrow_forward
- java program Add a divide method to the following program to take another Fraction as the parameter and return a new Fraction that is the division of current Fraction and the Fraction in the parameter. (public Fraction divide(Fraction f)). - Add scaleup and scaledown methods to the Fraction class. The scaleup method will take a factor as the parameter and multiply the numerator by the factor. The scaledown method will take a factor as the parameter and multiply the denominator by the factor. - Add a scale method that will have two parameters: factor and flag. The flag is boolean. If flag is true, then scale up the fraction; otherwise scale down the fraction. - Both scaledown and scale methods must check if the factor is 0. If it is 0, a warning message is printed out and no scaling is operated. - Add two more constructors. One of the constructors will have no parameters; it initializes the fraction to 0/1. The other constructor will have one parameter, representing the numerator of the…arrow_forwardIn c language using string h and complexo h and classes and ~ opertaorarrow_forwardWrite in python language thank youarrow_forward
- Finish the TestPlane class that contains a main method that instantiates at least two Planes. Add instructions to instantiate your favorite plane and invoke each of the methods with a variety of parameter values to test each option within each method. To be able to test the functionality of each phase, you will add instructions to the main method in each phase.arrow_forwardPyhton ProgramProgram the exercise and add the Screenshots of the output and inputarrow_forwardUsing python: (see attached- I need help with part Q2) Add a method to the person class name it (username) that takes the email and take off all the part from @ and after, and assigns the string before the @ sign to a variable username. For example: malabdullah@UT.edu, the method will assign 'malabdullah' as the username.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education