Question: You will write a program to convert the following temperatures in Fahrenheit to Celsius: 32 F, 72 F, 0 F, 212 F The conversion formula
You will write a program to convert the following temperatures in Fahrenheit to Celsius: 32 F, 72 F, 0 F, 212 F The conversion formula is the following:
where Tc is the temperature in Celsius and Tf is the temperature in Fahrenheit, and 32 is the freezing point of water. The subscripts in the formulae are for your understanding. You can use any relevant name for these variables or use the ones that are given the comments below. Below is the shell of the program that you would be creating. Create a class TemperatureConversion with a main method in it. Follow the instructions in the comments to complete the program. Include a multi-line comment at the beginning of the program that provides a brief description of the program.
public class TemperatureConversion
{
public static void main( String [] args )
{
// 1. Declare any constants here
// 2. Declare variables to store temp in Fahrenheit
// 3. Declare variables to store the results (temp in Celsius)
// 4. Calculate equivalent Celsius temperature and store results in // variables created in step 3.
// 5. Output the temperature in Celsius using verbose English // statements using Strings and String concatenation operators
}
}
Write a program to compute and output the perimeter of a circle (radius = 3.2 inches). Also, calculate the area of a circle having a radius of 3.2 inches. Follow the instructions provided in the shell program below as comments to complete this program. Make sure to comment your code appropriately. (You can search online for the formulae of perimeter and area of a circle). (10 Points)
Note: You can add a new Java class by right clicking the project folder in the navigation pane in NetBeans (left panel).
public class Circle
{
public static void main(String[] args)
{
//1. Declare any constants you would need
/*2. Declare variables you would need to store the radius, area and perimeter */
/*3. Perform appropriate calculations to calculate area and perimeter and assign it to the variables area and perimeter created in step 2. */
/*4. Output the area and perimeter. Ensure the output is verbose using Strings and String concatenation operator. */
}
}
Write a Java program that uses the elapsed time for an event in second and then outputs the elapsed time in hours, minutes and seconds. (For example, if the desired time is 9630 seconds, then the output is 2: 40: 30).
Use the elapsed time of 8732 seconds and output it as hours : minutes : seconds.
(Hint: Use Integer division and modulus operator)
In your NetBeans current java project directory, create a new class with a name SimpleDate. Now login to black board to copy the code of SimpleDate class from blackboard/course content/lecture slides/chapter 3/ chapter3.zip. You will see many files in this folder and you should open SimpleDate file in any text editor to open its code content. Copy this code and paste it within the SimpleDate class you created in NetBeans. Remember to remove public class SimpleDate {} before pasting the code because there can be only one class declaration with similar name. Once you have successfully copied the code, now you should write the following code in any other class file that has a main method (because we would want to run and test the code). You need to execute the following instructions in that class that has the main method:
Create an object (a.k.a. object reference) of SimpleDate class with default constructor and name it date.
PRINT the value of object reference date and explain why did you get this output?
Create a new object reference of SimpleDate class with constructor SimpleDate(int mm, int dd, int yy) and name it currentDate.
PRINT the value of object reference currentDate and explain why did you get this output?
Print the values of month, day and year using accessor methods.
Using mutator methods, set a new value of day, month and year to currentDate object. Use July 4th 1776 as the new value.
Print the value of currentDate object and explain why did you get this output?
Always give a thumbs up :)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
