Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to create a program using the Eclipse IDE that does the following, Use Case 1: As a user, when I enter three

I am trying to create a program using the Eclipse IDE that does the following,

  • Use Case 1: As a user, when I enter three of the same number, I want the program to tell me I have an equilateral triangle.
  • Use Case 2: As a user, when I enter two numbers that are the same and a third number that will create a triangle, I want the program to tell me I have an isosceles triangle.
  • Use Case 3: As a user, when I enter three different numbers that will create a triangle, I want the program to tell me I have a scalene triangle.
  • Use Case 4: As a user, when I enter three values that cannot create a triangle, I want the program to tell me, Not a Triangle.

My code currently is :

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.InputMismatchException; import java.util.Scanner;

public class Triangle { private static final Exception IOException = null; private static final boolean isTriangle = false; int side1,side2,side3; private static Scanner scanner; void triangle(int a, int b, int c){ side1 = a; side2 = b; side3 = c; } boolean isTriangle() { if (((side1 + side2) > side3) || ((side1 + side3) > side2) || ((side2 + side3) > side1)) return true; return false; } boolean isScalene() { return (side1 != side2 && side1 != side3); } boolean isIsosceles() { return (side1 == side2 && (side1 + side2)>side3 || side2 == side3 && (side2 + side3)>side1 || side1 == side3 && (side1 + side3)>side2); } boolean isEquilateral() { return (side1 == side2 && side1 == side3); } public static void main(String[] args) throws Exception{ throw IOException;

char in1 ='Y'; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); do { System.out.println("Enter the sides of the Triangle:"); int x,y,z; scanner = new Scanner(System.in); try { x=scanner.nextInt(); y=scanner.nextInt(); z=scanner.nextInt(); }catch (inputMistmatchExcpetion e) { System.out.println("You have input invalid numbers, only integer values are allowed for sides of a triangle"); System.out.println("Please try again. "); continue; } Triangle a,b,c; a = new Triangle(); boolean flag=a.isIsosceles(); if(flag) { System.out.println("It is an Isosceles triangle!");} else System.out.println("It is not an Isosceles triangle."); boolean flag1=a.isEquilateral(); if(flag1) { System.out.println("It is an Equilateral Triangle!");} else System.out.println("It is not an Equilateral Triangle."); boolean flag2=a.isScalene(); if(flag2) { System.out.println("It is a Scalene Triangle!");} else System.out.println("It is not a Scalene Triangle."); boolean isTriangle; if(isTriangle) { System.out.println("It is a Triangle."); }else { System.out.println("It is not a triangle."); break; } System.out.println("Sides of the triangle are:"+a.toString()); System.out.println("Do you want to Continue [Y/N]"); in1 =(char)in.read(); } while(in1=='y'||in1=='Y'); public string returnString() { return side1.toString() + ", " + side2.toString() + ", " + side3.toString(); } }

} I am getting the error on my ending string line of :

Exception in thread "main" java.lang.Error: Unresolved compilation problems: Syntax error on token "string", record expected string cannot be resolved to a type Illegal modifier for parameter returnString; only final is permitted Syntax error, insert "RecordBody" to complete RecordDeclaration

at Triangle.main(Triangle.java:79) If anyone could help me out I would greatly appreciate it, thank you.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions