Temperature Class
Write a Temperature class that will hold a temperature in Fahrenheit, and provide methods to get the temperature in Fahrenheit, Celsius, and Kelvin. The class should have the following field:
- fahrenheit – A double that holds a Fahrenheit temperature.
The class should have the following methods:
- Constructor – The constructor accepts a Fahrenheit temperature (as a double) and stores it in the ftemp field.
- setFahrenheit – The setFahrenheit method accepts a Fahrenheit temperature (as a double) and stores it in the ftemp field.
- getFahrenheit – Returns the value of the ftemp field, as a Fahrenheit temperature (no conversion required).
- celsius – Returns the value of the ftemp field converted to Celsius.
- kelvin – Returns the value of the ftemp field converted to Kelvin.
Use the following formula to convert the Fahrenheit temperature to Celsius:
Use the following formula to convert the Fahrenheit temperature to Kelvin:
Demonstrate the Temperature class by writing a separate
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Problem Solving with C++ (10th Edition)
Concepts Of Programming Languages
Database Concepts (8th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out with C++ from Control Structures to Objects (9th Edition)
- Using JAVASCRIPT write an object prototype for a Person that has a name and age, has a printInfo method, and also has a method that increments the persons age by 1 each time the method is called. Create two people using the 'new' keyword, and print both of their infos and increment one persons age by 3 years. Use an arrow function for both methods */ // Create our Person Prototype // Use an arrow to create the printInfo method // Create another arrow function for the addAge method that takes a single parameter // Adding to the agearrow_forwardDesign a class named RoseBushes. A rose has fields for a color (for example, “red”), a price for athree gallon bush (for example, 17.99), and a field that indicates whether the rose bush hasbloomed (for example, “Yes”).Finish creating the class diagram below and then write the pseudocode that defines the class.Hint: You will need set and get methods for each field.UML Class Diagram:RoseBushes-color : string-price : num-bloomed : string Pseudocode:arrow_forwardImplement the inventory manager class. This class must have methods that do the following: Add a new item to the inventory manager. Remove an item from the inventory manager. Re-stock an item in the inventory manager. Display the items in the inventory manager. Search for an item in the inventory manager by at least two criteria (name, price, quantity, etc.). Part 3: Test the inventory manager class with a driver program or unit tests. This may be a console application.arrow_forward
- Implement the following class Employee. This class is composed by 4 attributes and 3 methods. 1) Create a class Employee containing: _init_( ) method to initialize the different attributes . Get EmployeeName method Get EmployeeSSN method . Get EmployeeDepartment method 2) Define the method main to create 4 employees and apply the different methods Employee # Name: # Social Security Number: # Department # Salary + + Get Employee Name() Get Employee Social Security Number() + Get Employee Department() 3arrow_forwardCode the StudentAccount class according to the class diagramMethods explanation:pay(double): doubleThis method is called when a student pays an amount towards outstanding fees. The balance isreduced by the amount received. The updated balance is returned by the method.addFees(double): doubleThis method is called to increase the balance by the amount received as a parameter. The updatedbalance is returned by the method.refund(): voidThis method is called when any monies owned to the student is paid out. This method can onlyrefund a student if the balance is negative. It displays the amount to be refunded and set thebalance to zero. (Use Math.abs(double) in your output message). If there is no refund, display anappropriate message.Test your StudentAccount class by creating objects and calling the methods addFees(), pay() andrefund(). Use toString() to display the object’s data after each method calledarrow_forwardCreate a class Person to represent a person according to the following requirements: A person has two attributes: id Add a constructer to initialize all the attributes to specific values. Add all setter and getter methods. Create a class Product to represent a product according to the following requirements: A product has four attributes: a reference number (can’t be changed) a price an owner (is a person) a shopName (is the same for all the products). Add a constructer without parameters to initialize all the attributes to default values (0 for numbers, "" for a string and null for object). Add a second constructer to initialize all the attributes to specific values. Use the keyword "this". Add the method changePrice that change the price of a product. The method must display an error message if the given price is negative. Add a static method changeShopName to change the shop name. Add all the getter methods. The method getOwner must return an owner. Create the class…arrow_forward
- Part I Create a Ticket class. The design is up to you. Write the necessary methods. Part II Create a MovieTicket class that inherits from Ticket class. The design is up to you. Write the necessary methods. Part III Create a Theater class. The design is up to you. Write the necessary methods.arrow_forwardJava - Constructors Create a class named Book that has the following attributes: Publisher - String Year Published - Integer Price - Double Title - String Create a constructor for the class Book that has the parameters from the attributes of the class. After, create a method for the class that displays all attributes. Ask the user for inputs for the attributes and use the constructor to create the object. Lastly, print the values of the attributes. Inputs 1. Publisher 2. Year Published 3. Price 4. Book Title XYZ Publishing 2020 1000.00 How to Win? Sample Output Published: ABC Publishing Year Published: 2022 Price: 150.00 Book Title: Stooping too low Stooping too low is published by ABC Publishing on 2022. It sells at the price of Php150.00.arrow_forward⚫ Task 1: Create a Class Tasks Define a class named Person with attributes name and age. Write a method greet() that prints a greeting message including the person's name and age. ⚫ Task 2: Rectangle Class Create a class Rectangle that takes length and width as parameters. Add methods area() and perimeter() to calculate and return the area and perimeter of the rectangle. ⚫ Task 3: Object Interaction Create a Library class that contains a list of books and methods to add, remove, and list all books in the library. • Task 4: Movie Class Create a class Movie with attributes title, director, and rating. Add a method display_info() that prints the movie's details and a method rate_movie(new_rating) to update the movie's rating. • Task 5: Ticket Class(homework) Define a class Ticket' with attributes event_name, date, and price. Add methods apply_discount(discount_percentage) to reduce the price by a given percentage and display_ticket() to print the ticket details including the final price…arrow_forward
- A TV Class The attributes of a TV object are the channel, the volume, and a flag (or switch) indicating whether the TV is on or off. The methods perform the following actions: • Turn the TV on or off. • Set the channel to an integer from 0 to 99 inclusive. • Raise or lower the volume by one unit. The volume can range from 0 to 20. • View the value of the volume. • View the channel. • Determine whether the TV is on or off. Write a TV class that implements all relevant functions. A newly created TV object is set to off with the channel set to 2 and the volume initially 10. Include a main(...) method that tests the methods of the TV class.arrow_forwardA SuperDie Class Write a class SuperDie that models a single die with an arbitrary number of sides, not just six. A die instantiated with the default constructor has six sides. The methods of this class should be: • roll a die and return its value, • return the number of sides on a die, and • change the number of sides on a die. Include a main(...) method that tests all the methods of your class.arrow_forwardPlease help me solve this with java..I posted it many times and got rejected I don't ? Game class instructions:• Game class has three attributes: points (which represent the number of points awarded when winning the game), status (false if the game has not been played and true if the game has been played), and description (which is a text description of the game). Note that description attribute is a read-only variable. • In the constructor, initialize points to zero, status to false, and description to the given parameter.• isPlayed method returns true if the game has been played, and false otherwise.• getPoints is a getter method for points attribute.• play method is an abstract method.• Override toString method to return the game description.• Override equals method so that two games are the same if their descriptions are the same. :instructions class ) HangMan• HangMan is a game in which a player tries to guess a word based on a given hint. For example, if the given hint is…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,