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
Make the list of menu icon in MS Excel<br>​
valina [46]

●file

●home

●insert

●page layout

●formulas

●data

●review

●view

8 0
2 years ago
Sharing a workbook enables multiple users to access the workbook. What are the benefits of using a shared workbook?
damaskus [11]

Answer:

Some of the benefits of sharing a workbook include:

A. Shared information between students (ie: Mary writes a note about (blank) in the workbook and John reads said note and receives addition information about (blank)).

B. ^adding onto this, discussion on interpretations of a passage (ie: John thinks (blank) means this and Mary thinks (blank) means other thing, through notes they can discuss the meaning of the text.

Hope this helps. =)

8 0
3 years ago
After class, Anita and Bev make plans to study for their psychology exam together but cannot decide on a time or location. In ad
Paladinen [302]

Answer:

Option B; 30 SECONDS OR LESS.

Explanation:

Short-term memory, also known as primary or active memory, is the information we are currently aware of or thinking about.

When short-term memories are not rehearsed or actively maintained, they last mere seconds.

Most of the information kept in short-term memory will be stored for less than 30 seconds (approximately 20 to 30 seconds), but it can be just seconds if rehearsal or active maintenance of the information is not done.

Therefore, Anita likely will be able to retain the information in short-term memory, without additional processing, for 30 SECONDS OR LESS.

8 0
3 years ago
Write a program that will allow a grocery store to keep track of the total number of bottles collected for a seven-day period. T
Anna35 [415]

Answer:

  • Print the values days of bottles.
  • Display total number of bottles collecting.
  • Display the payout for this transaction.

Explanation:

Program:-

DEPOSIT_PER_BOTTLE = 0.10

another = "Y"

while another=="Y":

   print("Input Values 7 days of bottles:")

   total = 0

   for I in range(7):

       collected_bottles = int(input())

       total += collected_bottles

   payout = total*DEPOSIT_PER_BOTTLE

   print("Total number of bottles collected: {:,}".format(total))

   print("Payout for this transaction $%.2f"%payout)

   another = input("Do you want to complete another transaction? ").upper()

7 0
2 years ago
You have been tasked with ensuring that access to certain server managed resources is only available to client devices with TPM
elixir [45]

Answer:

Device Health Attestation Services

Explanation:

Based on the scenario being described it can be said that the Windows Server role that can be used to automate this check is known as Device Health Attestation Services. This is a role that allows the administrator to automatically check if a device has the required trustworthy BIOS, TPM, or boot software enabled, as well as Bitlocker encryption.

7 0
3 years ago
Other questions:
  • What is the single most important component of a computer? Central Processing Unit DIP Motherboard Chipset
    8·1 answer
  • FS and GS are two___________________ in protected mode.
    14·1 answer
  • What are the consequences of plagiarism?
    7·2 answers
  • Drag each tile to the correct box.
    11·1 answer
  • Develop Swimlane Activity diagram for Assignment announcement and submission system.
    6·1 answer
  • How can we style the images and layouts of our pages?
    8·1 answer
  • What is block chain?
    5·2 answers
  • You're doing desktop support and the company policy is that you can only help with company equipment. A user walks in:
    6·1 answer
  • What is a cyber crime?<br><br>help
    7·2 answers
  • What is the definition of Graphic AIDS?.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!