Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in Java (JGRASP) Below is my code: import java.util.Scanner; //needed scanner //create class MyTriangle public class MyTriangle { public static void main (string[] args) {

in Java (JGRASP)

Below is my code:

import java.util.Scanner; //needed scanner //create class MyTriangle public class MyTriangle { public static void main (string[] args) { // define Scanner Scanner input = new Scanner (System.in); // define a variable isvalid boolean isvalid = true; //inputting sides of a triangle System.out.println("Enter 3 sides of a triangle "); double s1 = input.nextDouble (); double s2 = input.nextDouble (); double s3 = input.nextDouble (); //store the result in isvalid isvalid = isvalid(s1,s2,s3); if (isvalid) System.out.println ("Area = "+ area (s1,s2,s3)); else //isvalid is false display the message System.out.println ("Invalid Input "); } // method is invalid public static boolean isvalid (double side1, double side2, double side3) { return (((side1 + side2) >side3) && ((side2 + side3) >side1) && ((side3 + side1) >side2)); } public static double area (double side1, double side2, double side3) { double s = (side1 + side2 + side3)/2; double area= Math.sqrt (s * (s - side1) * (s - side3)); return area; }//End main }//End class

I keep getting the following error:

MyTriangle.java:54: error: class, interface, or enum expected }//End class ^ 1 error

WHAT AM I DOING WRONG IN MY CODE THAT I NEED TO CORRECT?

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago