
Java programming language
I need the two classes ( the testing class and the class with the methods) to be combined into one class.
This is the program:
import java.util.Scanner;
//The Temperature Class Begins Here
public class Temperature {
private double ftemp;
//The constructor
public Temperature(double ftemp) {
this.ftemp = ftemp;
}
//Get farenheit Method
public double getFtemp() {
return ftemp;
}
//Set farenheit method
public void setFtemp(double ftemp) {
this.ftemp = ftemp;
}
// Get Celcius Method
public double getCelcius(double ftemp){
//double celcius = (double) (5/9) * (ftemp - 32);
double celcius = (ftemp-32)* (double)5/9;
return celcius;
}
// Get Kelvin Method
public double getKelving(double ftemp){
double Kelvin;
Kelvin = (ftemp-32)*(double)5/9 + 273.15;
return Kelvin;
}
}
//The Temperature Class Ends Here
//The Temperature Test Class with a main method begins Here
class TemperatureTest{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
//Prompt User for value in fahrenheit
System.out.println("Enter·a·Fahrenheit·temperature:");
double ftem = in.nextDouble();
//Making the instance of the Temperature class
Temperature temp = new Temperature(ftem);
//Outputing Results
System.out.println("The·temperature·in·Fahrenheit·i: "+ftem);
System.out.println("The·temperature·in·Celcius·is: "+ temp.getCelcius(ftem));
System.out.println("The·temperature·in·Kelvin·is: " + temp.getKelving(ftem));
}
}

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

- Given the following Date class public class Date { private int year; private int month; private int day; public Date() { /** Implementation not shown */ } public Date(int year, int month, int day) { /** Implementation not shown */ } public void print() { /** Implementation not shown */ } } assuming that months in the Date class are numbered starting at 1, which of the following code segments will create a Date object for the date September 20, 2020 using the correct constructor? Date d = new Date(); Date d = new Date(9,20); Date d = new Date(9,20,2020); Date d = new Date(2020,9,20); Date d = new Date(2020,20,9);arrow_forwardJava Questions - Based on the code, which answer out of the choices "1, 2, 3, 4, 5" is correct. Explanation is not needed, just please make sure that the answer you have chosen is the correct option. Thanks. Question is in attached picture.arrow_forwardThere is a class hierarchy that includes three classes: class Animal { protected int age; public int getAge() { return age; } public void setAge(int age) { this.age = age; }}class Pet extends Animal { protected String name; public String getName() { return name; } public void setName(String name) { this.name = name; }}class Cat extends Pet { protected String color; public String getColor() { return color; } public void setColor(String color) { this.color = color; }} Given the following object: Pet cat = new Cat(); Select all invalid method invocations.arrow_forward
- In Java, what allows for the manipulation of data variables in a class? Group of answer choices: Class Instance methods Public interface Encapsulationarrow_forwardComplete the partial declaration of Class Car: public class Car { // declare three private instance variables: color, speed, model // define a constructor with two parameters: c , m which will assign values to color and model. //define set and get method for all instance variables //define a method named calspeed( ) with int return type, the method will increase the speed by 50 mile per hour. } Complete the application below. public class CarApp { public static void main() { string color = blue; string model = C2021;i int speed = 80; // declare necessary object matching to the constructor definition // display the color and model on the screen // call the calspeed( ) method and display the new speed after calculation. } }arrow_forwardpublic class Cat { private int age; public Cat (int a) { age = а; } public int getAge() { return a; } } Which of the following best explains why the getAge method will NOT work as intended? The instance variable age should be returned instead of a, which is local to the constructor. The variable age is not declared inside the getAge method. The getAge method should be declared as private. The getAge method should have at least one parameter.arrow_forward
- Java A class always has a constructor that does not take any parameters even if there are other constructors in the class that take parameters. Choose one of the options:TrueFalsearrow_forwardjava program 1.Define a class named Circle 2. A Circle object stores a radius and the (x, y) coordinates of its center point using Point class (It should have at least two private fields to store x and y coordinates of a point, one constructor, a toString method, and a distance method). 3. Each Circle object should have 2 private fields, a Point object, and radius. Each Circle object should have the following public methods: Circle(p, radius) - Constructs a new circle with a center specified by the given Point p and with the given integer radius getCenter() - Returns point object for the center of the circle getRadius() - Returns the circle's radius. getArea() - Returns the area occupied by the circle, using the formula πr^2 getCircumference() - Returns the circle's circumference (distance around the circle), using the formula 2πr. toString() - Returns a string representation of the circle, such as "Circle[center=(75, 20),radius=30]" contains(p) - Returns true if the point p lies…arrow_forward2. Add a constructor for Animal class shown. The constructor should pass in a string parameter named "sound". 1 using System; 2 3 public class Animal 4 { 5 public string Sound { get; set; } public void Speak() { Console.Writeline("The dog says " + Sound); } 10 11 } 12 13 public class Program 14 { public static void Main() { 15 16 17 18 } 19 } A 00arrow_forward
- The weight of an object can be described by two integers: pounds and ounces (where 16 ounces equals one pound). Class model is as follows: public class Weight { private int pounds; private int ounces; public Weight(int p, int o) ( pounds=p+o/16: ounces = 0% 16: } Implement a method called subtract, which subtracts one weight to another. i.e. Weight w1 = new Weight(10.5): Weight w2 = new Weight(5.7): Weight w3= w1.subtract(w2):arrow_forwardJava Program This assignment requires one project with two classes. Class Employee Class Employee- I will attach the code for this: //Import the required packages. import java.text.DecimalFormat; import java.text.NumberFormat; //Define the employee class. class Employee { //Define the data members. private String id, lastName, firstName; private int salary; //Create the constructor. public Employee(String id, String lastName, String firstName, int salary) { this.id = id; this.lastName = lastName; this.firstName = firstName; this.salary = salary; } //Define the getter methods. public String getId() { return id; } public String getLastName() { return lastName; } public String getFirstName() { return firstName; } public int getSalary() { return salary; } //Define the method to return the employee details. @Override public String toString() { //Use number format and decimal format //to…arrow_forwardpublic class Accumulator { private int total private String name; public Accummulator (string name , int total) { this .name = name; this .total=total; } } 3. In a main method, create an object of Accumulator with the name as "Mary" and total as 100.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





