Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello! I have a question in regards to my current Java project assignment. I haven't been able to figure out the math portion of the

Hello! I have a question in regards to my current Java project assignment. I haven't been able to figure out the math portion of the project. My program outputs the correct first set of integers, but does not pass all test when other values are entered. The expected output differs because the new values entered do not compile the expected result. Only thee first test passes.
My Java code is the following:
import java.util.Scanner;
public class PillarConcreteCosts {
public static void main(String[] args){
final double prismBase =5.5;
final int CUBIC_FEET_PER_CY =27;
final double CONCRETE_COST_PER_CY =108.00;
final double prismHeight =13.2;
Scanner scanner = new Scanner(System.in);
System.out.println("Program to calculate pillar requirements");
System.out.println();
System.out.println("Building type (S, M, or H)?");
char buildingType = scanner.next().charAt(0);
scanner.nextLine();
System.out.println("City building is located in?");
String cityName = scanner.nextLine();
System.out.println("Two-letter state building is located in?");
String stateName = scanner.nextLine();
System.out.println("Pillar pentagon side length (in feet)?");
double sideLength = scanner.nextDouble();
System.out.println("Number of pillars needed?");
int numPillars = scanner.nextInt();
System.out.println();
System.out.println();
System.out.printf("%32s
", "Pillars for type "+ buildingType +" building in");
System.out.printf("%32s
", cityName);
System.out.printf("%32s
", stateName);
System.out.println();
double prismVolume =((5* Math.pow(sideLength,2))/(4* Math.tan(Math.PI /5)))* prismHeight;
double pyramidVolume =(1.0/24)*(5+ Math.sqrt(5))*(Math.pow(sideLength,3));
System.out.printf("Base prism volume %14.3f%n", prismVolume, "
");
System.out.printf("Topper pyramid volume %10.3f%n", pyramidVolume, "
");
System.out.printf("%32s
","----------","
");
double pillarVolume = prismVolume + pyramidVolume;
System.out.printf("One pillar volume %14.3f cubic feet%n", pillarVolume);
System.out.printf("%23s%17s%n","x","4 pillars");
double allPillars = pillarVolume *4.0;
System.out.printf("%32s
","----------","
");
System.out.printf("Volume all pillars %13.3f cubic feet%n", allPillars);
System.out.println();
double totalConcreteCY = Math.ceil(allPillars / CUBIC_FEET_PER_CY);
double totalCost = totalConcreteCY * CONCRETE_COST_PER_CY;
System.out.printf("20 cubic yards of concrete required for %d pillars%n", numPillars);
System.out.printf("with a total cost of $ %.2f%n", totalCost);
}
}
Expectect output:
Program to calculate pillar requirements
Building type (S, M, or H)?
City building is located in?
Two-letter state building is located in?
Pillar pentagon side length (in feet)?
Number of pillars needed?
Pillars for type M building in
San Antonio
TX
Base prism volume 130.811
Topper pyramid volume 4.168
----------
One pillar volume 134.979 cubic feet
x 4 pillars
----------
Volume all pillars 539.917 cubic feet
20 cubic yards of concrete required for 4 pillars
with a total cost of $ 2160.00
I think it's the math portion of my code. Can anyone help? Much appreciated!
image text in transcribed

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

Step: 3

blur-text-image

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

recall the principles of determining job worth

Answered: 1 week ago