Computer Science, asked by musamturay, 5 hours ago

In this lab, you will write a program that asks the user for:


The width of a square
The width of a rectangle
The height of a rectangle
Use the following String variable to store the values entered by the user. You can use this same variable for all three inputs from the user.


String input;
Use the following three int variables to store the values entered by the user that have been converted to ints using Integer.parseInt(input):


int sqWidth
int recWidth
int recHeight
Calculate the areas of each shape and store the values in the following variables:


sqArea
recArea

Answers

Answered by cuyoscodybrynt
2

Answer:

Mobile legend ISA got mo

Answered by shilpa85475
0

The area of square is side * side

the area of rectangle is length * breadth

Explanation:

import java.util.Scanner;  

public class abc

{

   public static void main(String[] args)

{

       try (Scanner scanner = new Scanner(System.in))

{

           System.out.println("Enter Side of Square:");

           // Storing the captured value in a variable

           int sqWidth=Integer.parseInt(sqWidth);

           // Area of Square = side*side

           int sqArea = side * side;

           System.out.println("Area of Square is: " + sqArea);

 System.out.println("Enter the width of Rectangle:");

           int recWidth = Integer.parseInt(recWidth);

           System.out.println("Enter the height of Rectangle:");

int recHeight = Integer.parseInt(recHeight);

         

           

           int recArea = recHeight* recWidth;

           System.out.println("Area of Rectangle is:" + recArea);

       }

   }

}

Similar questions