Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do you you Scanner method; input ( ) marked! Here is the output that I want

ID: 3923783 • Letter: H

Question

How do you you Scanner method;

input ( ) marked!

Here is the output that I want to show --------------------------

Information for figure 1: Type 1) rectangle 2) triangle 3) circle (1)

height? (3.0)

width? (3.0)


Information for figure 2: Type 1) rectangle 2) triangle 3) circle (2)

base? (3.0)

height? (3.0)

  
rectangle area = 9.0

triangle area = 4.5


The rectangle seems to be bigger. -------------

Those things are available to shown as an output.

The rectangle seems to be bigger than the triangle.

The triangle seems to be bigger than the rectangle.

The triangle and rectangle seem to be equal.

Explanation / Answer

Hi, Please find my code.

I have implemented for option=1, like that you can implement for other option by yourself by taking help from my code, so that you can also get some concept.

import java.util.Scanner;

public class Test {

  

   public static void main(String[] args) {

      

       // creating scanner method

       Scanner sc = new Scanner(System.in);

      

       int option;

      

       System.out.println("Type 1) rectangle 2) triangle 3) circle");

       option = sc.nextInt();

      

       if(option == 1){

          

           System.out.print("height ? ");

           double height = sc.nextDouble();

           System.out.print("width ? ");

           double width = sc.nextDouble();

          

          

           System.out.println("Type 1) rectangle 2) triangle 3) circle");

           option = sc.nextInt();

           if(option == 1){

               System.out.print("base ? ");

               double base = sc.nextDouble();

               System.out.print("height ? ");

               double height1 = sc.nextDouble();

              

               double rectArea = height*width;

               double triangleArea = height1*base*0.5;

              

               System.out.println("rectangle area = "+rectArea);

               System.out.println("triangle area = "+triangleArea);

              

               if(rectArea > triangleArea){

                   System.out.println("The rectangle seems to be bigger than the triangle.");

               }else if(triangleArea > rectArea){

                   System.out.println("The triangle seems to be bigger than the rectangle.");

               }else{

                   System.out.println("The triangle and rectangle seem to be equal.");

               }

           }

       }

   }

}

/*

Sample output:

Type 1) rectangle 2) triangle 3) circle

1

height ? 3.0

width ? 3.0

Type 1) rectangle 2) triangle 3) circle

1

base ? 3.0

height ? 3.0

rectangle area = 9.0

triangle area = 4.5

The rectangle seems to be bigger than the triangle.

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote