1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
icang [17]
3 years ago
8

Write a program that reads the lengths of the sides of a triangle from the user. Compute the area of the triangle using Heron's

formula (below), in which s represents half of the perimeter of the triangle and a, b, and c represent the lengths of the three sides. Print rhe area to three decimal places.
Area= √ s(s-a)(s-b)(s-c)
Computers and Technology
1 answer:
slamgirl [31]3 years ago
3 0

Answer:

The java program is as follows.

import java.util.Scanner;

import java.lang.*;

public class Area

{

   //variables to hold the values

   static double a, b, c;

   static double s;

   static double area;

public static void main(String[] args) {

    //scanner class object created

    Scanner sc = new Scanner(System.in);

 System.out.print("Enter the first side: ");

 a=sc.nextInt();

 System.out.print("Enter the second side: ");

 b=sc.nextInt();

 System.out.print("Enter the third side: ");

 c=sc.nextInt();

 s=(a+b+c)/2;

 //function of Math class used

 area = Math.sqrt( s*(s-a)*(s-b)*(s-c) );

 //result displayed with 3 decimal places

 System.out.printf("The area of the triangle is %.3f", area);  

}

}

OUTPUT

Enter the first side: 1

Enter the second side: 1

Enter the third side: 1

The area of the triangle is 0.433

Explanation:

1. The variables to declare the three sides of the triangle, the semi-perimeter and the area of the triangle are declared with double datatype. All the variables are declared at class level and hence, declared with keyword, static.  

2. Inside main(), an object of the Scanner class is created.

Scanner sc = new Scanner(System.in);

3. Using the Scanner class object, user input is taken for all the three sides of the triangle.

4. Following this, the semi-perimeter is computed as shown.

s=(a+b+c)/2;

5. The area of the triangle is computed using the given formula which is implemented as shown.

area = Math.sqrt( s*(s-a)*(s-b)*(s-c) );

6. The sqrt() method of the Math class is used while computing the area of the triangle.

7. The area is displayed with three decimals. This is done using the printf() method as shown.

System.out.printf("The area of the triangle is %.3f", area);

8. The program is saved with the same name as the name of the class having the main() method.

9. The class having the main() method is always public.

You might be interested in
Is a book considered technology?
kumpel [21]
Yes, "technology" doesn't have to be all about computers or cell phones.. Technology is anything that is a new advance in knowledge and books were once a great advance in that field.
7 0
3 years ago
Read 2 more answers
Why is it now difficult for computer technology to maintain the pace of
KatRina [158]

It now difficult for computer technology as manufacturing cannot keep up with overwhelming transistor demand.

<h3>What was Moore's Law ?</h3>

Moore's Law is the one that talks about the fact that the number of transistors on a microchip is one that often goes up about two years always, even if the cost of computers is reduced.

Based on the above, It now difficult for computer technology as manufacturing cannot keep up with overwhelming transistor demand.

Learn more about computer technology  from

brainly.com/question/24912812

#SPJ1

6 0
2 years ago
What is earning potential?
Natalka [10]

Answer:

Earning potential often refers to the top salary for a particular field or profession. In the finance world, the meaning is not much different: earning potential is the biggest profit a company could potentially make.

Explanation:

Earning potential often refers to the top salary for a particular field or profession. In the finance world, the meaning is not much different: earning potential is the biggest profit a company could potentially make.

4 0
3 years ago
Your personal opinion about what a "successful" console in the future will need to include to sell well. How have the changes in
Marizza181 [45]

Answer:

The answer is below

Explanation:

In my personal opinion what a "successful" console in the future will need to include to sell well is "a big library of games." This feature will help a console supports many games that will appeal to all categories of gamers.

The changes in technology, gaming culture, and overall society has affected the game market in many ways such as:

1. In terms of technology: it has made the game manufacturers both the console and third-party game developers to improve their gaming features. For example, the advancement in gaming pads becoming wireless. The gaming console having internet or online features, where gamers can play with each other around the world from their rooms. Also, the gaming character design looking more and more like the real-life personality it represents.

2. In terms of gaming culture: modern games are no longer for teenagers alone. It is now appealing to adults as well. This is evident in football players and coaches playing the games and talking about it. Even some players tend to influence their ratings in the game by mentioning how good they are in the press in comparison to the rating game developers are giving them.

3. Overall society has now seen gaming consoles as part of everyday life. The parents, researchers, and even feminist groups are now well aware of the gaming industry. And each of the stakeholders involved is influenced by how the game consoles manufacturers market their games through media, sports personalities, celebrities, etc.

4 0
3 years ago
What is the purpose of the GETPIVOTDATA function?
Mrac [35]

Answer:to export the PivotTable data into another worksheet

Explanation:hope this helps :D

7 0
3 years ago
Read 2 more answers
Other questions:
  • Interpretations of​ Moore's law assert​ that:
    13·1 answer
  • An iPad Is An Example Of Which Type Of Computer?
    11·2 answers
  • Which type of financial institution typically has membership requirements?
    9·2 answers
  • ____________ are collected from several entities at the same point in time.
    13·1 answer
  • Explain how SEO impacts the way you should interpret search engine results ???
    6·1 answer
  • What type of web provides a framework that allows data to be shared and reuse to deliver
    9·1 answer
  • My brainly isnt working it isnt showing and answers wats going on? wat do i do
    14·2 answers
  • In a finite state machine, state transitions happen only: a. When the reset causes a clock pulse on the D outputs of the flip-fl
    11·1 answer
  • Pie charts are best used for
    5·1 answer
  • Describe your previous personal or professional experience with Microsoft Word.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!