CodeGym
Promotion
CodeGym University
Learning
Course
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Start learning now
  • All questions
AJITA SINGH
Level 2
Vishakhapatnam
  • 14.03.2019
  • 1435views
  • 3comments

what is wrong with my code.I cannot meet one of the conditons that is 3. The convertCelsiusToFahrenheit method should not display anything.

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 F; F = 9/5.0*celsius+32; System.out.println(F); return 0; } }
0
Comments (3)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Guadalupe Gagnon
Level 37 , Tampa, United States
14 March 2019, 13:57
line 16 fails the condition "The convertCelsiusToFahrenheit method should not display anything." line 17 should return F and not 0, this is why the last condition is failing "The convertCelsiusToFahrenheit method must correctly convert degrees Celsius to degrees Fahrenheit and return the result."
+1
AJITA SINGH
Level 2 , Vishakhapatnam, India
14 March 2019, 15:38
why does line 16 fail the condition?can you please specify, it would be really helpful
0
Guadalupe Gagnon
Level 37 , Tampa, United States
14 March 2019, 16:17solution
it specifically says the method should not display anything. line 16 is displaying F
+2
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.