Concept explainers
To add three new varibales max, min, and increment of type double in a new class Heater. The value of the max and min are set by the user and variable increment is set to 5.0 using the constructor. Two methods warmer() and cooler() are used to change the temperature by 5.0 using the variable increment. The value of the variable max and min is used to control max and min temperature of warmer and cooler() functions, respectively.
Program Plan:
Write a program in BlueJ to add the three new variable max, min, and increment of the type double. The value for the field increment is set to 5.0 using the constructor and can be used to change the temperature by 5 degrees by using the method warmer() and cooler. The method setIncrement() is used to change the value of increment.
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
- Implement the FindText() function, which has two strings as parameters. The first parameter is the text to be found in the user provided sample text, and the second parameter is the user provided sample text. The function returns the number of instances a word or phrase is found in the string. In the PrintMenu() function, prompt the user for a word or phrase to be found and then call FindText() in the PrintMenu() function. Before the prompt, call cin.ignore() to allow the user to input a new string.Ex: Enter a word or phrase to be found: more "more" instances: 5arrow_forwardFor this exercise, you are given 3 Object class objects and 3 Ball class objects. In theory, all three Objects are the same and all 3 Ball objects are the same, but based on the way they are created and the way that Java evaluates equality, not all three objects will be equal. Your task is to start by printing out the 6 Object and Ball objects. Remember, the Object class has a toString and since a Ball object extends the Object class, we should see similarities between the Object and Ball class. After printing them out, you should notice which objects are the same. Write 2 true and false statements for each group, one using == and one using .equals. Will these be the same? ========================================= public class TestEquals{public static void main(String[] args){System.out.println("** Object **");Object obj1 = new Object();Object obj2 = new Object();Object obj3 = obj1;// Print out all three objects // Print a true statement using 2 objects and == // Print a false…arrow_forwardI need help finishing up a HW assignment for my data structures class and dont know if i selected the right answers or noarrow_forward
- The code given below represents a saveTransaction() method which is used to save data to a database from the Java program. Given the classes in the image as well as an image of the screen which will call the function, modify the given code so that it loops through the items again, this time as it loops through you are to insert the data into the salesdetails table, note that the SalesNumber from the AUTO-INCREMENT field from above is to be inserted here with each record being placed into the salesdetails table. Finally, as you loop through the items the product table must be update because as products are sold the onhand field in the products table must be updated. When multiple tables are to be updated with related data, you should wrap it into a DMBS transaction. The schema for the database is also depicted. public class PosDAO { private Connection connection; public PosDAO(Connection connection) { this.connection = connection; } public void…arrow_forwardIn this program, you are provided with phenotype counts of F1 and F2 offspring at two research institutes. The data are generated from an initial parental cross of elegant cranes, whose genetics are identical to fruit flies, with the exception that they look like crane birds. The cranes for each institute come from the same original source. For each institute, in the parental generation (P0), one parent displays the wild-type (WT) phenotype and one the disease phenotype. The WT parent always has a homozygous genotype, and whether the disease parent has a homozygous genotype depends on which scenario describes data in the F1 generation. The possibilities for F1 individuals are: (a) All individuals are disease; (b) All individuals are wild-type; (c) There are disease and wild-type individuals. When both disease and WT individuals (item (c)) are available in the F1 generation then you should use the F1 cross, (disease) X WT. For each institute, there are three possible modes of…arrow_forwardDiscuss the relationship between parameterList and argumentList. If the first parameter has the integer data type and the second parameter has the Double data type, what data types should the first and second arguments have?arrow_forward
- Implement the design of the Pizza class so that the following output is produced:[Your code should work for any number of parameters added in the set_toppings_info method]# Write your codes here.print("Pizza Count:", Pizza.pizza_count)print("=======================")p1 = Pizza("Chicken")p1.set_toppings_info(25, 1, 4, 0)p1.display()print("------------------------------------")p2 = Pizza("Olives")p2.set_toppings_info(15, 1.5, 0, 0)p2.display()print("------------------------------------")p3 = Pizza("Sausage")p3.set_toppings_info(50, 5, 2, 0)p3.display()print("=======================")print("Pizza Count:", Pizza.pizza_count)Output:Pizza Count: 0=======================Toppings: Chicken25 calories1 g fat4 g protein0 g carbs------------------------------------Toppings: Olives15 calories1.5 g fat0 g protein0 g carbs------------------------------------Toppings: Sausage50 calories5 g fat2 g protein0 g carbs=======================Pizza Count: 3arrow_forwardAlthough the book focused on the normalization process only up to the Third Normal Form (3NF), there are actually four more commonly recognized normal forms – Boyce-Codd Normal Form (BCNF), Fourth Normal Form (4NF), Fifth Normal Form (5NF), and Sixth Normal Form (6NF). Research the uses of these other normal forms, then pick one to give a brief explanation of to the class. please pick one .arrow_forwardDoes the implementation of enumeration types allow for quick access to frequently used operators, such as the arithmetic and stream operators? Is it possible to get a satisfying outcome by, say, overloading these operators? What are the benefits and drawbacks of this approach?arrow_forward
- In this project, a rational number is defined as a fraction in which the numerator and denominator are integers with the denominator being non-zero. Requirements To ensure consistency among solutions each implementation must implement the following requirements. • Your implementation should reflect the definition of a simplified rational number at all times. • A long (integer) is used to represent both the numerator and denominator. • The Rational class must be able to handle both positive and negative numbers. • The rational number must be in simplest form after every operation; that is, 8 6 shall be immediately reduced to 4 3 . In order to simplify a rational number properly, use the the Euclidean Algorithm to determine the greatest common divisor of the two numbers. • All methods that have an object as parameter must be able to handle an input of null. • By definition, the denominator of a fraction cannot be zero since it leads to an undefined value. In Java, this division by zero…arrow_forwardUSING C++ Overload the = operator for your Rectangle class, Rectangle class is below, it should return a Rectangle in order to support multiple assignments in one line, e.g. a = b = c;. Copying from the pdfs is acceptable, but make sure you understand how it works. Overload the < and > operators in Rectangle to determine if one rectangle is bigger than the other, based on area. Demonstrate that your new operators work by writing a simple main() function to show they work. *** Rectangle Class *** Rectangle.hclass Rectangle{private:double width;double length;char* name;void initName(char* n);public:Rectangle();Rectangle(double, double,char*);//Copy ConstructorRectangle(Rectangle&);~Rectangle();Rectangle& operator=(const Rectangle&);...}; ****End of Rectangle Class**** ****Overloaded = operator, returns a rectangle by reference**** Rectangle.cpp Rectangle& Rectangle::operator=(const Rectangle& r){length = r.length;width = r.width;strcpy(name, r.name);return…arrow_forwardWrite java class for student with properties Name Marks And construtor to set data and one compareMarks method which will compare marks of two student and will return max marksarrow_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