Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Plesae solve in java Write an interactive program that computes the area of a square (area = side2) or triangle (area = 1/2 * base

Plesae solve in java

Write an interactive program that computes the area of a square (area = side2) or triangle (area = 1/2 * base * height) after prompting the user to type the first character of the figure name (t or s). Note that a square does not have a base and a height. It has only a side. Your variable names should reflect this.

Sample screen output 1:

Enter the type of figure (s or t): t Enter the base: 4 Enter the height: 3 The area is 6 Sample screen output 2:

Enter the type of figure (s or t): s Enter the length of a side: 9 The area is 81 You should read the user's input as a String using the input.next() method.

You may need to compare two Strings in order to complete this. You can't compare Strings using the == operator. You'll need to use the "equals()" method. It will look something like

if (string1.equals(string2))... Turn in your source code and 2 outputs, one reflecting each of the two sample screen outputs given above.

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

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

Students also viewed these Databases questions

Question

7. Explain why retirees may be valuable as part-time employees.

Answered: 1 week ago

Question

3. Provide advice on how to help a plateaued employee.

Answered: 1 week ago