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
J_DJ
Level 4
Saint Louis
  • 05.05.2020
  • 470views
  • 4comments

I typed the return statment but why does it not see the return? it says illegal start type

Question about the task Time conversion
Java Syntax,  Level 3,  Lesson 5
Under discussion

Add a public static int convertToSeconds(int hour) method that converts hours to seconds.
Call it twice in the main method with any arguments.
Display the results, each time on a new line.

Requirements:
  • Add the convertToSeconds method. It must be public static, and take and return ints.
  • The convertToSeconds method must convert the passed number of hours to seconds.
  • The main method must call the convertToSeconds method twice.
  • The main method should display the result of the calls, each time on a new line.
  • The convertToSeconds method should not display anything.
package com.codegym.task.task03.task0312; /* Time conversion */ public class Solution { public static int converToSeconds(int hour); int s = hour * 3600; return s; } public static void main(String[] args) { System.out.println(converToSeconds(1)); System.our.println(converToSeconds(2)); } }
0
Comments (4)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
J H U X
Level 7 , Alkmaar, Netherlands
11 January 2021, 10:02
You typed: public static int converToSeconds(int hour); But it should be: public static int convertToSeconds(int hour) { There is a type too in convertToSeconds on which CodeGym will say you failed the test, although it would've worked in the real world. Another typo in the second System.out.println. Good luck!
0
Sujit Mahato
Level 4 , Mumbai, India
5 September 2020, 17:33
you take semicolon " ;" after declare method make it correct as public static int convertToSecends(int hour) after this if you take semicolon " ; ". then program should be given error .
0
Gellert Varga
Level 23 , Szekesfehervar, Hungary
5 May 2020, 22:07useful
Line 9: To declare a method is not like this: converToSeconds(...); it seems like a command. Method declaration is like this: converToSeconds(...) (curly brucket!) Line 16: 'our' or 'out' ? :)
+1
Gellert Varga
Level 23 , Szekesfehervar, Hungary
5 May 2020, 22:08
converToSeconds(int hour) {
+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.