CodeGym
Promotion
CodeGym University
Learning
Course
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Question
  • Reviews
  • About us
Start
Start learning
Start learning now
  • All questions
Ana Georgievska
Level 2
Skopje
  • 04.11.2018
  • 1380views
  • 6comments

Can someone help pls, what is wrong...

Question about the task Our first converter!
Java Syntax,  Level 2,  Lesson 2
Resolved


The convertCelsiusToFahrenheit(int celsius) method accepts a value in degrees Celsius. The method should convert the temperature and return the value in degrees Fahrenheit.
The Celsius temperature (TC) and the Fahrenheit temperature (TF) are related by the following relationship:
TF = (9 / 5) * TC + 32.

Consider this example:
A value of 41 is passed to the convertCelsiusToFahrenheit method.

Example output:
105.8

Requirements:
  • The convertCelsiusToFahrenheit(int) method must be public and static.
  • The convertCelsiusToFahrenheit method must return a double.
  • The convertCelsiusToFahrenheit method should not display anything.
  • The convertCelsiusToFahrenheit method must correctly convert degrees Celsius to degrees Fahrenheit and return the result.
package com.codegym.task.task01.task0130; /* Our first converter! */ public class Solution { public static void main(String[] args) { System.out.println(convertCelsiusToFahrenheit(41)); } public static double convertCelsiusToFahrenheit(int celsius) { double fahrenheit = (41 * 1.8) + 32; return fahrenheit; } }
0
Comments (6)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Aaron
Level 2 , Germantown, United States
6 December 2018, 15:55
Why is it + 32 when the formula is - 32
0
Aswini
Level 4 , Chennai, India
13 November 2018, 07:20
public class Solution { public static void main(String[] args) { System.out.println(convertCelsiusToFahrenheit(41)); } public static double convertCelsiusToFahrenheit(int celsius) { //write your code here double fahrenheit = 9 / 5.0 * celsius + 32; return fahrenheit; } }
-2
Krishna shahi
Level 3 , Uttarakhand, India
4 November 2018, 11:39
May this will help you- public class Solution { public static void main(String[] args) { System.out.println(convertCelsiusToFahrenheit(41)); } public static double convertCelsiusToFahrenheit(int celsius) { double TF=(double)((celsius)*9.0/5.0)+ 32; return TF; } }
+4
Ana Georgievska
Level 2 , Skopje, Macedonia, The Former Yugoslav Republic of
4 November 2018, 23:49
It works.Thanks
0
Krishna shahi
Level 3 , Uttarakhand, India
5 November 2018, 14:04
Always welcome dear . For further help you can DM me. And please press '+' sign in my first comment.
0
Ashish RajAnand
Level 13 , Bhilai , India
6 November 2018, 05:06
Here I mention that 9/5 is always gives only integer data i.e. 1 not 1.8 Only you need to convert it 9/5 integer data type to double data type i.e. 9 / 5 = 1 9.0 / 5 = 1.8 9 / 5.0 = 1.8 9.0 / 5.0 = 1.8 for example celsius*9.0/5+32 celsius*9/5.0+32 celsius*9.0/5.0+32 This is basic concept . one more thing you can convert int celsius to double by using (double)celsius
0
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Game Projects
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning and Java developer’s career.
Follow us
Interface language
Programmers Are Made, Not Born © 2023 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2023 CodeGym
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.