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
Swati
Level 8
Pune
  • 23.10.2018
  • 1481views
  • 3comments

error in return type int

Question about the task More conversions
Java Syntax,  Level 3,  Lesson 8
Resolved

Implement the getFeetFromInches(int inches) method. The method takes the number of inches. Your task is to make the method return the number of full feet represented by the variable inches. (1 feet = 12 in).

Consider this example:
The getFeetFromInches method is called with the argument 243.

Example output:
20

Requirements:
  • The getFeetFromInches(int) method must be public and static.
  • The getFeetFromInches method must return an int.
  • The getFeetFromInches method should not display anything.
  • The getFeetFromInches method must correctly return the number of full feet represented by the variable inches.
package com.codegym.task.task01.task0131; /* More conversions */ public class Solution { public static void main(String[] args) { System.out.println(getFeetFromInches(28)); } public static int getFeetFromInches(int inches) { //write your code here // int fet = Math.round(0.8333); double Feet = 0.83 * inches; int Fet = (int) Math.round(Feet); return Fet; } }
0
Comments (3)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Robert P
Level 20 , Nashville, United States
24 October 2018, 04:36
You are making this harder that it needs to be. In the imperial measurement system, there are 12 inches per foot (plural feet) No conversion to decimal is needed, Java can do the work for you. !!! The condition asks for whole feet only. There is no need for <double> Example: 37 inches converted to feet according to the condition would be 3 feet. Example: 14 inches converted would be 1 foot. Example: 26 inches would be 2 feet. Ignore the remainder.
+2
Jaisingh
Level 14 , Hyderabad, India
24 October 2018, 02:21
1/12 = 0.0833 ... i guess so change the conversion value... it will be verified then...!!
0
Michael Martin
Level 19 , Arlington, United States
23 October 2018, 17:44
Your conversion from inches to feet is incorrect. It is not .83
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.