Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program 2: Triangle 1. Create a Java class named Triangle.java 2. Your program will calculate the area of a triangle using integers. The area of

image text in transcribed
image text in transcribed
Program 2: Triangle 1. Create a Java class named Triangle.java 2. Your program will calculate the area of a triangle using integers. The area of a triangle is base height. Prompt the user for the base as an integer, and then prompt for the height (also as an integer). 1. If the user enters any value that is less than or equal to zero for the base or height, your program should not perform any calculations and instead print "Invalid input 2. If both the base and height values from the user are greater than zero, calculate and display the area of the triangle. Sample output is shown below Enter the base: 7 Enter the height: 5 The area of the triangle is: 17.5 The area of the triangle is: 28.0 Enter the base: 7 Enter the height: 8 Enter the base: Enter the height: 4 Invalid input Enter the base: 6 Enter the height: -3 Invalid input

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

In Facebook, why is it important to get to know your fans?

Answered: 1 week ago

Question

What is java? and can you explain the java? or describe the java?

Answered: 1 week ago