hi i recently started a java class and received my 1st assignment. Its alot harder than i woulda thought and im kinda stuck and need abit of help.
if im doing this right ive declared my variable and made them all user imputs but im confused on how to set up the calculations.help would be greatly appreciated, heres the criteria:
also anything relating to area was me trying random things that didnt work.
Write a program that computes the cost of painting and installing carpet in a room. Assume that the room has one door, two windows, and one book-shelf. Your program must do the following:
a. Prompts the user to enter, in feet, the length, width, and height of a room. Read the dimensions of the room.
b. Prompts the user to enter the widths and heights, in feet, of the door, each window, and the bookshelf. Read these quantities.
c. Prompts the user to enter the cost, per square foot, of painting the walls. Read these quantities.
d. Prompts the user to enter the cost, per square foot, of installing carpet. Read these quantities.
e. Outputs the cost of painting the walls and installing the carpet.
:import java.util.Scanner; public class Assignment1 { public static void main(String[] args) { Scanner in = new Scanner (System.in); int Height; int Width; int Length; int DLength; int DWidth; int W1Length; int W1Width; int W2Length; int W2Width; int BLength; int BWidth; int FloorCost; int WallCost; System.out.println("ROOM Height"); Height = in.nextInt(); System.out.println("ROOM Width"); Width = in.nextInt(); System.out.println("ROOM Length"); Length = in.nextInt(); int Area = Length * Width; //area of the floor int Tarea = Length * Width * Height * 4; //area of the 4 walls System.out.println("DOOR Height"); DLength = in.nextInt(); System.out.println("DOOR Width"); DWidth = in.nextInt(); int Area1 = DLength * DWidth; //area of the door System.out.println("WINDOW1 Height"); W1Length = in.nextInt(); System.out.println("WINDOW1 Width"); W1Width = in.nextInt(); int Area2 = W1Length * W1Width; //area of the 1st window System.out.println("WINDOW2 Height"); W2Length = in.nextInt(); System.out.println("WINDOW2 Width"); W2Width = in.nextInt(); int Area3 = W2Length * W2Width; //area of the 2nd window System.out.println("BOOKSHELF Height"); BLength = in.nextInt(); System.out.println("BOOKSHELF Width"); BWidth = in.nextInt(); int Area4 = BLength * BWidth; //area of the bookshelf System.out.println("FloorCost per sqaurefeet"); FloorCost = in.nextInt(); System.out.println("WallCost per sqaurefeet"); WallCost = in.nextInt(); int TotalAREA = Area1 + Area2 + Area3 + Area4; //total area of everything minus the floor and walls System.out.println("The Cost of Painting the walls" + (Tarea - TotalAREA) * WallCost); System.out.println("The Cost of install carpet is " + Area * FloorCost); } }