Skip to content

Instantly share code, notes, and snippets.

@PramodDutta
Created April 23, 2024 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PramodDutta/33ce998bdf9382c80ca3654bee1da315 to your computer and use it in GitHub Desktop.
Save PramodDutta/33ce998bdf9382c80ca3654bee1da315 to your computer and use it in GitHub Desktop.
Problem with the Java pROGRAM
package src.ex_23042024;
import java.util.Scanner;
public class Lab079 {
public static void main(String[] args) {
//✅ Triangle Classifier:
//
// Write a program that classifies a triangle based on its side lengths.
// Given three input values representing the lengths of the sides, determine
// if the triangle is equilateral (all sides are equal),
// isosceles (exactly two sides are equal), or
// scalene (no sides are equal).
// Use an if-else statement to classify the triangle.
// side1, side2, side3 ->
Scanner sc = new Scanner(System.in);
System.out.println("Enter the side1,side2,side3, I will tell about the triangle");
int side1 = sc.nextInt();
int side2 = sc.nextInt();
int side3 = sc.nextInt();
// = Assign the value
// == compare the values
if((side1 == side2) && (side1 == side3) && (side2 == side3)){
System.out.println("EQ");
}else if((side1 == side2) || (side1 == side3) || (side2 == side3)){
System.out.println("ISO");
}else{
System.out.println("Scalene!");
}
}
}
@PramodDutta
Copy link
Author

How to fix this issue?

@1009168
Copy link

1009168 commented Apr 25, 2024

My program is not running. It is giving below error
error1 "class PositiveNegativeChecker is public, should be declared in a file named PositiveNegativeChecker.java"
error2 "cannot find symbol variable sc"

My Code:

package JavaBasicCodes;

import java.util.Scanner;

public class PositiveNegativeChecker {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the Number: ");
int num = sc.nextInt();
PNChecker(num);
}
public static void PNChecker(int num){
if (num >= 1){
System.out.println("Positive Number");
}else if (num < 0){
System.out.println("Negative Number");
}else {
System.out.println("Zero");
sc.close();
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment