Task 1:
Building contractor
You are developer and you wish to build five new houses, all from wood and all uniform.
Each house has 3 rooms, all with exactly the same dimensions, i.e. 2m x 4m. Wood prices
have been set at £6.00 per meter.
You need to determine the total cost of the build of all five houses. Initially, you will need
to write the pseudocode to solve the following problem, define the variable name and data
types, plus write the code to solve the total build cost.
Hint: Determine the area of each room in each house and the total area of all rooms
combined. Thus, giving the total price of the construction. in java
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int house = 5;
int room = 3;
int len = 2;
int we = 4;
double cost = 6;
int areaRoom = len * we;
int totalArea = areaRoom * room * house;
double totalCost = totalArea * cost;
System.out.println("Room area: " + areaRoom);
System.out.println("Area of all rooms: " + totalArea);
System.out.println("Total price of the construction: " + totalCost);
}
}
Comments
Leave a comment