Question

2. (20 points) Write a method that accepts a temperature in Fahrheit as a parameter and returns that same temperature in Celsius. For example, if your method were called with the parameter 212, it would not print anything but would return 100. Name CSCI 161-(01.02.03)-Homework 02-Page 2 3. (20 points) Write a main method that prints a table of the Celsius equivalents of every 5tlh Fahrenheit temperature between 20 and 90. Assume that this is in the same class as the previous problem. Output should look something like this: 20 25 30 35 40 45 50 -6.666666666666667 -3.888888888888889 1.6666666666666667 4.444444444444445 7.222222222222222 10.0 60 65 70 75 80 85 90 15.555555555555555 18.333333333333332 23.88888888888889 26.666666666666668 29.444444444444443 32.22222222222222

Need the answer in Java, thank you!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program 2:

import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the temperature in Fahrenheit: ");
double fahrenheit = in.nextDouble();
double celsius = (fahrenheit-32)*(0.5556);
System.out.println("Temperature in Celsius: "+celsius);
}
}

Stdin Inputs... 212 Result... CPU Time: 8.21 sec(s), Memory: 33868 kiLobyte(s) Enter the temperature in Fahrenheit: Temperature in Celsius: 100.008

Program 3:

import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.println("F\tC");
for(int i = 20; i <= 90; i = i + 5){
double fahrenheit = i;
double celsius = (fahrenheit-32)*(0.5556);
System.out.println(fahrenheit + "\t" +celsius);
}
}
}

Let me know if you have any queries or clarifications.... :)

Add a comment
Know the answer?
Add Answer to:
Need the answer in Java, thank you! 2. (20 points) Write a method that accepts a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a JAVA program that has a method which accepts a string and prints it back...

    Write a JAVA program that has a method which accepts a string and prints it back to the user with all vowels replaced with *'s (multiple asterisks not '*s') with a new line after the string. The method signature should look like this: public static void replacePrint(String input)

  • write program in java 5. Falling Distance When an object is falling because of gravity, the...

    write program in java 5. Falling Distance When an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period: d = 1/2 gta The variables in the formula are as follows: d is the distance in meters, g is 9.8, and t is the amount of time, in seconds, that the object has been falling. Write a method named fallingDistance that accepts an object's falling time...

  • I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that a...

    I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...

  • Java Program Write a method called reverseBottomHalf that accepts a Stack of integers as a parameter...

    Java Program Write a method called reverseBottomHalf that accepts a Stack of integers as a parameter and reverses only the values in the bottom half of the Stack. For example, if a Stack containing the values [1, 2, 3, 4, 5] were passed in (with 1 at the bottom and 5 at the top), the Stack would be changed to [2, 1, 3, 4, 5] (with 2 at the bottom and 5 at the top) after this method was called...

  • In java, write method, shuffle, which accepts an array of int, creates a copy of the...

    In java, write method, shuffle, which accepts an array of int, creates a copy of the formal parameter, shuffles the copy, then returns the copied, shuffled array, leaving the formal parameter unchanged. Shuffling is a process of swapping each element of array with another element randomly chosen from the array. For testing the shuffle method have main call shuffle, repeatedly having it shuffle its previously returned array until the returned (shuffled) array is identical (equal) to the original array that...

  • Submit Chapter7.java with four (4) public static methods as follows: A. Write a method called mostCommon...

    Submit Chapter7.java with four (4) public static methods as follows: A. Write a method called mostCommon that accepts an array of integers as its only parameter, and returns the int that occurs most frequently. Break ties by returning the lower value For example, {1,2,2,3,4,4} would return 2 as the most common int. B. Write mostCommon (same as above) that accepts an array of doubles, and returns the double that occurs most frequently. Consider any double values that are within 0.1%...

  • please I need it urgent thank in java please 1. (20 pts) a) Write a method...

    please I need it urgent thank in java please 1. (20 pts) a) Write a method (function) that is passed an array of int and returms the largest element in the array b) Write a method (function) that is passed an array of int and returns the smallest element in the array. e) Write a method (function) that is passed an array of int and returns the average of the elements in the array

  • Please code in Java and ignore question 2, thank you! 1. Write a Java method that...

    Please code in Java and ignore question 2, thank you! 1. Write a Java method that takes as its only input parameter a single integer, n, and returns the number of unique binary search trees that can be constructed with integers 1 through n. (Hint: You'll probably want to do this recursively.) (Note: This is not asking for the number of maximally tall BSTs. The BSTs can be any height.) 2. Work through the deletion exercises in 2-4-deletion-supplementary.pdf (attached above)....

  • Please I need help. Java language Method name: getScores Return value is a String of numbers...

    Please I need help. Java language Method name: getScores Return value is a String of numbers scaled so that the highest number in the parameter String becomes 100 and all the other numbers are moved up by the same amount. This String should also be numbers separated by spaces with no additional characters. The order of the numbers should stay the same, so that a number in the original string has the equivalent scaled number in the returned string in...

  • Please use public class for java. Thank you. 1. (10 points) Write a method that computes...

    Please use public class for java. Thank you. 1. (10 points) Write a method that computes future investment value at a given interest rate for a specified number of years. The future investment is determined using the formula futurelnvestmentValue numberOfYears 12 investmentAmount X ( monthlyInterestRate) Use the following method header: public static double futurelnvestmentValue( double investmentAmount, double monthlyInterestRate, int years) For example, futureInvestmentValue 10000, 0.05/12, 5) returns 12833.59. Write a test program that prompts the user to enter the investment...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT