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
-Dominant- [34]
3 years ago
5

Write a test program that prompts the user to enter three sides of the triangle (make sure they define an actual triangle), a co

lor, and a Boolean value to indicate whether the triangle is filled.
Computers and Technology
1 answer:
Ivanshal [37]3 years ago
7 0

Answer:

   Scanner in = new Scanner(System.in);

       System.out.print("Please enter 3 sides of a triangle, color and " +

                       "whether it is filled or not (true false): ");

       double s1 = in.nextDouble();

       double s2 = in.nextDouble();

       double s3 = in.nextDouble();

       String color = in.next();

       boolean filled = in.nextBoolean();

       

       Triangle t1 = null;

       

       try {

           t1 = new Triangle(s1, s2, s3, color, filled);

       }

       catch (IllegalTriangleException ite) {

           System.out.println(ite.toString());

       }

       

       System.out.println(t1.toString());

       System.out.printf("Triangle color: %s, Triangle filled: %s%n" +  

                       "Area: %.2f%n" +  

                       "Perimeter: %.2f%n%n",

                   t1.getColor(),  

                   t1.isFilled(),

                   t1.getArea(),

                   t1.getPerimeter());

           

Explanation:

   Scanner in = new Scanner(System.in);

       System.out.print("Please enter 3 sides of a triangle, color and " +

                       "whether it is filled or not (true false): ");

       double s1 = in.nextDouble();

       double s2 = in.nextDouble();

       double s3 = in.nextDouble();

       String color = in.next();

       boolean filled = in.nextBoolean();

       

       Triangle t1 = null;

       

       try {

           t1 = new Triangle(s1, s2, s3, color, filled);

       }

       catch (IllegalTriangleException ite) {

           System.out.println(ite.toString());

       }

       

       System.out.println(t1.toString());

       System.out.printf("Triangle color: %s, Triangle filled: %s%n" +  

                       "Area: %.2f%n" +  

                       "Perimeter: %.2f%n%n",

                   t1.getColor(),  

                   t1.isFilled(),

                   t1.getArea(),

                   t1.getPerimeter());

           

You might be interested in
Write programs for two MSP430 boards to do the following:
Rainbow [258]

Answer:

Explanation:

#include "msp430g2553.h"

#define TXLED BIT0

#define RXLED BIT6

#define TXD BIT2

#define RXD BIT1

const char string[] = { "Hello World\r\n" };

unsigned int i; //Counter

int main(void)

{

WDTCTL = WDTPW + WDTHOLD; // Stop WDT

DCOCTL = 0; // Select lowest DCOx and MODx settings

BCSCTL1 = CALBC1_1MHZ; // Set DCO

DCOCTL = CALDCO_1MHZ;

P2DIR |= 0xFF; // All P2.x outputs

P2OUT &= 0x00; // All P2.x reset

P1SEL |= RXD + TXD ; // P1.1 = RXD, P1.2=TXD

P1SEL2 |= RXD + TXD ; // P1.1 = RXD, P1.2=TXD

P1DIR |= RXLED + TXLED;

P1OUT &= 0x00;

UCA0CTL1 |= UCSSEL_2; // SMCLK

UCA0BR0 = 0x08; // 1MHz 115200

UCA0BR1 = 0x00; // 1MHz 115200

UCA0MCTL = UCBRS2 + UCBRS0; // Modulation UCBRSx = 5

UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**

UC0IE |= UCA0RXIE; // Enable USCI_A0 RX interrupt

__bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ int until Byte RXed

while (1)

{ }

}

#pragma vector=USCIAB0TX_VECTOR

__interrupt void USCI0TX_ISR(void)

{

P1OUT |= TXLED;

UCA0TXBUF = string[i++]; // TX next character

if (i == sizeof string - 1) // TX over?

UC0IE &= ~UCA0TXIE; // Disable USCI_A0 TX interrupt

P1OUT &= ~TXLED; }

#pragma vector=USCIAB0RX_VECTOR

__interrupt void USCI0RX_ISR(void)

{

P1OUT |= RXLED;

if (UCA0RXBUF == 'a') // 'a' received?

{

i = 0;

UC0IE |= UCA0TXIE; // Enable USCI_A0 TX interrupt

UCA0TXBUF = string[i++];

}

P1OUT &= ~RXLED;

}

7 0
4 years ago
Is this website real? Or is it a scam?
nikitadnepr [17]

It's a scam don't buy something

5 0
3 years ago
If you want to clear an operating system's temporary files for storage, performance, or privacy reasons, you should run a disk _
VashaNatasha [74]

Answer:

Cleanup is correct:)

Explanation:

8 0
2 years ago
The mode is least appropriate for:___________
bazaltina [42]

Answer:

Your question seems incomplete

Explanation:

7 0
3 years ago
When creating a table in html, ____ marks the content of a header cell.?
alexandr402 [8]
<th> .............,........
8 0
3 years ago
Other questions:
  • The Mesozoic is known as the _________
    7·1 answer
  • What is the average reading rate for middle school students?
    12·1 answer
  • Write a program that asks the user to enter a series of numbers separated by commas. Here is an example of valid input: 7,9,10,2
    6·1 answer
  • Suppose that we are using PDDL to describe facts and actions in a certain world called JUNGLE. In the JUNGLE world there are 4 p
    7·1 answer
  • One condition for deadlocks is the circular-wait condition. One way to ensure that this condition never holds is to impose a tot
    12·2 answers
  • Ben is writing web page content on a newly launched gaming gadget. He has to use hyperlinks to help visitors navigate to web pag
    11·1 answer
  • Can someone help me in my IT (information technology) homework
    10·2 answers
  • Which are options in the Form Tools Format tab?
    10·1 answer
  • As a sports store owner, the higher the price you charge for gear...
    8·2 answers
  • FOR CALL OF DUTY MOBILE GAMERS PLS HELP!
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!