Тёмный

5.6. Celsius Temperature Table - Java 

Kakra Detome
Подписаться 18 тыс.
Просмотров 7 тыс.
50% 1

Starting out with Java: From control structures through objects
Chapter 5
Programming Challenges
6. Celsius Temperature Table
The formula for converting a temperature from Fahrenheit to Celsius is
C = 5/9(F - 32)
where F is the Fahrenheit temperature and C is the Celsius temperature. Write a method named celsius that accepts a Fahrenheit temperature as an argument. The method should return the temperature, converted to Celsius. Demonstrate the method by calling it in a loop that displays a table of the Fahrenheit temperatures 0 through 20 and their Celsius equivalents.
Gaddis, Tony (2015-05-29). Starting Out with Java: From Control Structures through Objects (Page 313). Pearson Education. Kindle Edition.
Learn Java - • Learn Java
Learn Python - • Learn Python
Programming challenges, Starting out with Java by Tony Gaddis - • Programming challenges...
Programming challenges, Starting out with Python by Tony Gaddis, • Programming challenges...
Thanks 😊

Опубликовано:

 

14 ноя 2016

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 19   
@shawna9786
@shawna9786 5 лет назад
I had to create two methods. 1 as described above and then a second to do the reverse. For some reason it is not reading the second method calculation correctly. Do you have a video on that?
@KakraDetome
@KakraDetome 5 лет назад
Update: I made a video of a Celsius to Fahrenheit conversion table here, ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-OEGVcqbngj0.html. Please let me know if you have any questions ok 😊 Take care 😊 Hi Shawna, if you're trying to create the reverse as in, trying to create a program that will display the Fahrenheit equivalent for Celsius temperatures 0 to 20, create a function named fahrenheit that will take in a celsius temperature as an argument and return the fahrenheit equivalent. It will look like this, public static double fahrenheit( double celciusTemperature ) { double fahrenheit; fahrenheit = ( (double)9 / 5 ) * celciusTemperature + 32; return fahrenheit; } ... The formula to convert from Celsius to Fahrenheit is F = ( 9 / 5 ) * C + 32, where F is the Fahrenheit temperature and C is the Celsius temperature. It's important to note that, 9 / 5 will result in an integer although the answer is a double. That's because 9 / 5, typed this way is an integer division because both operands are integers. If you want the calculation to result to its actual answer, which is a double, one of the values, any of them, it could be the 9 or the 5, has to be type casted to a double. That's why I type casted the 9 to a double by typing the double keyword in parenthesis in front of it. Then write a loop that will loop 20 times, calling the fahrenheit() function above 20 times to get the Fahrenheit equivalent. Following a similar approach to what we did above, it will look like this, public static void main( String [ ] args ) { displayHeader(); double fahrenheitEquivalent; for( double currentCelciusTemperatureIndex = 0; currentCelciusTemperatureIndex
@shawna9786
@shawna9786 5 лет назад
@@KakraDetome Thank you so much! I look forward to seeing where I went wrong in my programming. I have it displaying the two tables but it isn't calling the math methods correctly so the conversions are incorrect. I really appreciate your taking the time to respond to my question! Thank you!
@KakraDetome
@KakraDetome 5 лет назад
@@shawna9786 No thanks at all 😊 Always always welcome 😊 Please let me know how it goes and don't worry ok, we'll work through it. Please keep me updated and take care 😊
@henokzerihun4272
@henokzerihun4272 7 лет назад
can you do the Test Average and Grade please
@KakraDetome
@KakraDetome 7 лет назад
Hello Henok, 5.7. Test Average and Grade - Java, will be posted tomorrow ok. You should be able to check back in the Starting out with Java programming challenges, ru-vid.com/group/PLGFLoZ9w5xCP2OFHwY6EZq-IIG7JFcdHQ and see it ok. Take care :)
@henokzerihun4272
@henokzerihun4272 7 лет назад
okay thanks
@KakraDetome
@KakraDetome 7 лет назад
No thanks at all Henok :) You're very much welcome :)
@KakraDetome
@KakraDetome 7 лет назад
Hello Henok, here it is, 5.7. (Part 1) Test Average and Grade - Java, ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-tq4hUCOueds.html 5.7. (Part 2) Test Average and Grade - Java, ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ueMXsoVWSRI.html Please let me know if you have questions ok :) Take care Henok :)
@henokzerihun4272
@henokzerihun4272 7 лет назад
thanks, can you do Conversion Program next i'm stuck on it
Далее
Simulating the Evolution of Rock, Paper, Scissors
15:00
Java 8 STREAMS Tutorial
18:10
Просмотров 731 тыс.
CelsiusToFahrenheit.java
7:14
Просмотров 2 тыс.
Python OOP Tutorial 1: Classes and Instances
15:24
Просмотров 4,4 млн
Learn SOLID Principles with CLEAN CODE Examples
28:35
Просмотров 264 тыс.
Optionals In Java - Simple Tutorial
15:53
Просмотров 201 тыс.