Using java write a class called temperature

Assignment Help Computer Engineering
Reference no: EM132170651

Using JAVA

Write a class called Temperature that has two instance variables: a temp value (a floating-point number - data type double) and a character for the scale, either ‘C' for Celsius or ‘F' for Fahrenheit.

The class should have a constructor that sets each instance variable (assume zero degrees if no temp value is specified and Celsius if no scale is specified), and it should include the following methods:

1. two accessor methods: one to return the degrees Celsius and the other to return the degrees Fahrenheit- use the following formulas to write the two methods: DegreesC = 5(degreesF - 32)/9 DegreesF = (9(degreesC)/5) + 32

2. three mutator methods: one to set the value, one to set the scale ( F or C ), and one to set both;

3. a comparison method: it should return -1 if the invoking temperature is less than the argument temperature, 0 if they are equal and 1 if the invoking temperature is greater than the argument one;

4. a toString method: returns a String representing the calling Temperature object. The numeric value of the temperature should be rounded to the nearest tenth of a degree. For example, System.out.println(new Temperature(98.164555, F)); //should print: 98.2 F

Then write a driver program called TempTester that tests all the methods from the Temperature class. Example tests: 0.0 degrees C = 32.0 degrees F, -40.0 degrees C = -40.0 degrees F, and 100.0 degrees C = 212.0 degrees F.

Reference no: EM132170651

Questions Cloud

Write a program for a given an input integer array : Using java ,write a program for a given an input integer array, lower bound lb and upper bound ub.
Using java write a recursive method static int intsquareroot : Using java Write a recursive method static int intSquareRoot(int n) {} // return the biggest number whose square is = 0.
What change in toyota demand will result : Assuming there is a $1 increase in the price of gasoline, what change in Toyota demand will result (give the numerical value, too)?
Write a javascript function which accepts an argument : Write a JavaScript function which accepts an argument and returns the type. Output returned value to console.log(). Submit HTML with external JS file.
Using java write a class called temperature : Using JAVA Write a class called Temperature that has two instance variables: a temp value (a floating-point number - data type double) and a character.
Print the adjacency matrix of the graph : Implements Prim's algorithm for finding the minimum spanning tree of a weighted graph. Your program should conform to the following specifications.
Cost-reducing technological process : For each event below, explain if demand or supply would shift and in what direction. What would the effect be on equilibrium price and quantity?
Write a program that first ask the user to enter real number : Print the sum if all three numbers are positive, print the product of the two positive numbers if only one is negative - use one nested if.
Yield the maximum net benefits : Suppose total benefits and total costs are given by B(Y) = 100Y - 8Y2 and C(Y) = 10Y2. What level of Y will yield the maximum net benefits?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Create your own function in c that accepts one input number

Prepare your own Function Create your own function in C that accepts one input number and returns a double number.

  Explain why the java dynamic dispatch algorithm

Explain why the Java dynamic dispatch algorithm, which looks for the method to invoke for a call o.a(), will never get into an infinite loop.

  What is scaffolding in a program and when is it used

What is scaffolding in a program, and when is it used? Give two methods for testing a program, and discuss when each should be used.

  Write a program that prints the square of the product

Write code statements to create a DecimalFormat object that will round a formatted value to four decimal places. Then write a statement that uses that object.

  Define various types of electronics equipment

Design and implement a set of classes that define various types of electronics equipment (computers, cell phones, pagers, digital cameras, etc.).

  Create a processing program to simulate a indexed imaging

Assignment: Color Indexing and Dithering- Create a Processing program to simulate a indexed imaging and implement Floyd-Steinberg dithering.

  Generate and display on the console the elements

Generate and display on the console the elements of a one-dimensional array b[M] where each element of b[M] represents the average grade over the semester of each of the M students .

  Write a script file that finds the smallest even integer

Use a script file to write a script file that finds the smallest even integer that is divisible by 13 and 16 whose square root is greater than 120.

  Process used to detect and correct transmission errors

process used to detect and correct transmission errors.

  Explain some of the examples of poor quality in it projects

discuss some of the examples of poor quality in it projects presented in the what went wrong? section. could most of

  How can codes be broken

How can codes be broken? What are transposition and substitution ciphers? The response must be typed.

  Discuss examples of roles you would separate and why

Discuss examples of roles you would separate and why. Submit a summary of your learning as a bulleted list that explains importance of separation of duties.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd