Computers and Technology

Class Main { public static void main(String[] args) {

Scanner sc = new Scanner(System. in);

DecimalFormat roundMoney = new DecimalFormat("0.00");

int pyraHeight;

double cost, pyraVolume, baseLength;

System. out. print( "Enter the integer height of the pyramid:");

pyraHeight = sc. nextInt();

System. out. print( "Enter the decimal base length of the pyramid:");

baseLength= sc. nextDouble();

pyraVolume= 1/3 * (Math. pow(baseLength,2)) * pyraHeight;

if(pyraVolume>50){

cost=13 * pyraVolume;

}

else{

cost=18 * pyraVolume;

}

System. out. print( "The volume of the pyramid is "+ pyraVolume);

System. out. println( " cubic inches");

System. out. print( "The cost to make the pyramid is $"+roundMoney. format(cost));

}

}

This is my code and my output for the volume makes no sense at all. It keeps saying 0.0 and that affects the cost as well. Please help me.

Enter the integer height of the pyramid:7
Enter the decimal base length of the pyramid:4.6
The volume of the pyramid is 0.0 cubic inches
The cost to make the pyramid is $0.00

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 20:30, winnie45
To display data in a certain manner like alphabetical order is called
Answers: 1
image
Computers and Technology, 22.06.2019 13:00, ajayfurlow
Which option should u select to ignore all tracked changes in a document
Answers: 1
image
Computers and Technology, 22.06.2019 23:00, cchotshot
Is an attack that relies on guessing the isns of tcp packets
Answers: 2
image
Computers and Technology, 23.06.2019 07:30, Braxtonw875
What part of the interface displays the external references contained in a selected cell? the status bar the review tab the scroll bar the formula bar
Answers: 1
Do you know the correct answer?
Class Main { public static void main(String[] args) {

Scanner sc = new Scanner(System....

Questions in other subjects:

Konu
Mathematics, 13.11.2020 01:00
Konu
Mathematics, 13.11.2020 01:00
Konu
Mathematics, 13.11.2020 01:00
Konu
English, 13.11.2020 01:00