Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java program in intellij IDEA Community You have been asked by Black and Gold Construction Company to write a program to help them compare construction

Java program in intellij IDEA Community

You have been asked by Black and Gold Construction Company to write a program to help them compare construction costs on different projects. Your program computes the cost per square foot of floor space for a given building based on its total cost and the buildings dimensions. For simplicity, all buildings will be rectangular, given as the buildings length and width. The cost of a building is given as width * length * cost per square foot * floors + base cost of the building. For instance, a building that is 3 floors and is 200x300 feet with a cost per square foot of $11 and a base cost of $250,000 has a total cost of 200 * 300 * 11 * 3 + 250,000 = $2,230,000. For our program, we will know the dimensions of the building, the number of floors, the base cost and the overall cost. We will use these to compute the cost per square foot. Our formula is given below (you should be able to figure out the formula yourself with a little algebra):

Cost per square foot = (cost base cost) /

(width * length * number of floors)

Note that all input will be given as int values but cost per square foot should be a double. You will have to perform a cast.

Start your program with an identifying comment header similar to the one in Lab 1. Next, declare the following six variables.

int length, width, nStories;

int baseCost, totalCost;

double squareFootCost;

You will not input the length, width, nStories, baseCost or totalCost from the user. Instead, we will hard-code these values in the program using assignment statements, for instance length = 200; Initially, use the following values to test your program.

length of foundation

200

width of foundation

300

number of floors

3

base cost

$250,000

total cost

$2,000,000

Next, include your assignment statement to compute the squareFootCost. Remember to provide any proper casts needed so that you obtain an accurate squareFootCost value. Finally, finish the program by outputting the results. Use the following two statements.

System.out.println("The cost per square foot of floor space for a "

+ length + " by " + width + " building");

System.out.println("of " + nStories + " stories with a base cost of "

+ baseCost + " and a total cost of " + totalCost

+ " is " + squareFootCost + ".");

Compile and run your program. If everything works correctly, you should see the following text in the console window.

The cost per square foot of floor space for a 200 by 300 building

of 3 stories with a base cost of 250000 and a total cost of 2000000 is 9.722222222222221.

The output of the cost per square foot looks ugly, nothing like a dollar amount. Java contains many built-in classes that can do all sorts of things for us such as handle keyboard or file input, generate random numbers, create GUI components and also format floating precision numbers.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

Students also viewed these Databases questions