Modify the program from Project 4 to compute the area of a triangle. Issue the appropriate prompts for the triangle’s base and height, and change the name of the width variable to base. Use the formula 0.5 × base × height to compute the area. An example of the program input and output is shown below: Enter the base: 5 Enter the height: 7 The area is 17.5 square units.
Modify the program from Project 4 to compute the area of a triangle. Issue the appropriate prompts for the triangle’s base and height, and change the name of the width variable to base. Use the formula 0.5 × base × height to compute the area. An example of the program input and output is shown below: Enter the base: 5 Enter the height: 7 The area is 17.5 square units.
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter2: Problem Solving Using C++using
Section: Chapter Questions
Problem 8PP: (Modify) a. Modify the program you wrote for Exercise 7 to provide the mass of a person as an...
Related questions
Question
Modify the program from Project 4 to compute the area of a triangle.
- Issue the appropriate prompts for the triangle’s base and height, and change the name of the width variable to base.
- Use the formula 0.5 × base × height to compute the area.
An example of the program input and output is shown below:
Enter the base: 5 Enter the height: 7 The area is 17.5 square units.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
Java Code
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Enter the base: ");
double base = scan.nextDouble();
System.out.print("Enter the height: ");
double height = scan.nextDouble();
System.out.println("The area is " + 0.5*base*height +" square units");
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning