CodeGym
Promotion
CodeGym University
Learning
Courses
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
CodeGym/Help with Java Tasks/Y'all the code for "the triangle is not possible" is not ...
Alex Balandinos
Level 18
Lusaka
  • 2/7/19
  • 1982views
  • 5comments

Y'all the code for "the triangle is not possible" is not working some help would be cool...

Question about the task Rule of the triangle
Java Syntax,  Level 4,  Lesson 4
Resolved


Use the keyboard to enter three numbers a, b, and c (the lengths of the sides of the proposed triangle).
Determine whether a triangle with these sides can exist.
Display the result as follows:
"The triangle is possible." - if a triangle with these sides could exist.
"The triangle is not possible." - if a triangle with these sides cannot exist.

Hint:
A triangle can exist only if the sum of two of its sides is greater than the third side.
You need to compare each side with the sum of the other two.
If even one side is larger or equal to the sum of the other two sides, then no such triangle exists.

Requirements:
  • The program should read three numbers from the keyboard.
  • The program should display text on the screen according to the task conditions.
  • If a triangle with the specified sides could exist, you need to display: "The triangle is possible."
  • If a triangle with the specified sides cannot exist, you need to display: "The triangle is not possible."
package com.codegym.task.task04.task0415; /* Rule of the triangle */ import java.io.*; import java.util.Scanner; public class Solution { public static void main(String[] args) throws Exception { //write your code here // BufferedReader bufferedReader = new BufferedReader(new InputStreamReader( System.in)); // String lenA= bufferedReader.readLine(); Scanner scanner = new Scanner(System.in); int a= scanner.nextInt(); int b= scanner.nextInt(); int c= scanner.nextInt(); if (c<=(a+b) && b<= (a+ c) && a<=(b+c)) System.out.println("The triangle is possible."); if (c >(a+b) || b>(a+b) || a>(b+c)) System.out.println("The triangle is not possible."); //else // System.out.println("The triangle is not possible."); } }
0
Comments (5)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Alex Balandinos
Level 18 , Lusaka, Zambia
7 February 2019, 12:49
Works with else block thanks for the tip though
0
Alex Balandinos
Level 18 , Lusaka, Zambia
7 February 2019, 12:40
So I replace if block with an else block
0
kapil
Level 12 , delhi, India
7 February 2019, 12:22solution
try by removing "=" sign from line 21 also there is no need of line 23, 24 comment out line 25, 26
+2
Alex Balandinos
Level 18 , Lusaka, Zambia
7 February 2019, 12:41
Yo ..I replace the if block on line 23 with an else block
0
kapil
Level 12 , delhi, India
7 February 2019, 12:45
now it works or not
0
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • 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 a Java developer’s career.
Follow us
Interface language
English
Deutsch Español हिन्दी Français Português Polski বাংলা 简体中文 मराठी தமிழ் Italiano Bahasa Indonesia 繁體中文 Nederlands 日本語 한국어 Bulgarian Danish Hungarian Basa Jawa Malay Norwegian Romanian Swedish Telugu Thai Українська Filipino Turkish Azərbaycan Русский Vietnamese
Programmers Are Made, Not Born © 2026 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2026 CodeGym