Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java .not c++ Write an interactive program that computes the area of a square (area = side 2 ) or triangle (area = 1/2 *

java .not c++

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_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

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions

Question

Were all members comfortable brainstorming in front of each other?

Answered: 1 week ago

Question

5. What information would the team members need?

Answered: 1 week ago