Food Festival at HillTown HillTown Inn is planning to organize a Food Festival bringing together at one place, a wide variety of cuisines from across the world on account of Christmas. The Hotel Management has rented out a square hall of an indoor Auditorium for this extravaganza. The side of the square hall is y inches in which a large square table is placed for the display of the most popular and celebrated food items. The side of the square table is x inches, such that x<y. The Management wanted to fill the remaining floor area with a decorative carpet. To get this done, they needed to know the floor area to be filled with the carpet. Write a program to help the Management find the area of the region located outside the square table but inside the square hall. Input Format: The first line of the input is an integer y, the side of the square hall. The second line of the input is an integer x, the side of the square table placed for display. Output Format: The output should display the area of the floor that is to be decorated with the carpet. Refer sample input and output for formatting specifications. [All text in bold corresponds to input and rest corresponds to output.] Sample Input Output 7 3 The area to be decorated is 40 Sample Input and Output 2: 5 2 The area to be decorated is 21
package demo; import java.util.Scanner; public class DemoTranslation { public static void main(String[] args) { int x, y, z; System.out.println("Enter the side of the square hill"); x = STDIN_SCANNER.nextInt(); System.out.println("Enter the side of the square table placed for display"); y = STDIN_SCANNER.nextInt(); z = x * x - y * y; System.out.print("Area to be decorated is " + z); } public final static Scanner STDIN_SCANNER = new Scanner(System.in); }
Quote:he side of the square table is x inches, such that x<y.
z = x * x - y * y;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)