Assignment

As a civil engineer, you are frequently required to provide approximate estimate of the number of tiles required to furnish floor spaces. Write a simple program to help you complete this task as quickly as possible.
a. Pseudo code
b. Flowchart 
c. Code implementation 

a. Pseudo code 

                           Start
* Input the length of the floor (L)
* Input the width of the floor (W)
* Input the length of the tile (l)
* Input the width of the tile (w)
* Calculate the area of floor = L*W
* Calculate the area of one tile = l*w
* Calculate the number of tiles required (N)= floor area/tileArea
* Round up to the nearest whole number (since you can't use a fraction of a tile)
* Output N
                           End



b. Flowchart 

                            Start 
                                |
                    Input L,W,l,w
                                |
                    floorArea=L*W
                     tileArea=l*w
                                 |
                    N=floorArea/tileArea 
                                  |
                      Round up N
                                  |
                      Output N
                                  |
                                End



C. Code implementation 

import java.util.Scanner;
public class TileCalculator {
    public static void main(String... args){
    Scanner scanner = new Scanner(System.in);
    // calculate the length of floor space
    System.out.println("Enter the length of the rectangle(in metres): ");
    double floorLength = scanner.nextDouble();
    // calculate the width of the floor space
    System.out.println("Enter the width of the floor space(in metres): ");
    double floorWidth = scanner.nextDouble();
    // calculate the length of the tile
    System.out.println("Enter the length of the tile(in metres): ");
    double tileLength = scanner.nextDouble();
    // calculate the width of the tile
    System.out.println("Enter the width of the tile(in metres): ");
    double tileWidth = scanner.nextDouble();
        // calculate the area of the floor space
        double floorArea = floorLength*floorWidth;
        // calculate the area of the tile
        double tileArea = tileLength*tileWidth;
        // calculate the numtiles required
        double numtiles = floorArea/tileArea;
        int numTilesRequired = (int) Math.ceil(numtiles);
        // print out the result
        System.out.println("The number of tiles required is:"+ numTilesRequired);
        scanner.close();
    } 
}
               

Comments

Popular posts from this blog

Assignment

Assignment