CodeGym
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
Online Learner
Level 6
  • 21.06.2019
  • 938views
  • 2comments

can anyone help me this out

Question about the task Minimum of three numbers
Java Syntax,  Level 2,  Lesson 8
Resolved


Write a function that computes the minimum of three numbers.

Hint:
You need to write the body of the existing min function.

Requirements:
  • The program should display text on the screen.
  • The min method should not display text on the screen.
  • The main method should call the min method four times.
  • The main method should display the result of the min method. Each time, on a new line.
  • The min method must return the minimum of the numbers a, b, and c.
package com.codegym.task.task02.task0216; /* Minimum of three numbers */ public class Solution { public static int min(int a, int b, int c) { //write your code here if(a<=b) return a; else if(b<=c) return b; else return c; } public static void main(String[] args) throws Exception { System.out.println(min(1, 2, 3)); System.out.println(min(-1, -2, -3)); System.out.println(min(3, 5, 3)); System.out.println(min(5, 5, 10)); } }
0
Comments (2)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Sabiha Khan
Level 3 , Khopoli, India
22 June 2019, 16:55
you have to use nested if else. if(a < b){ if(a < c){ return a;} else{ return c;}} else{ if(b < c){ return b;} else{ return c;}}
0
Online Learner
Level 6
23 June 2019, 08:43
thanks
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.