Write a java code prompting the user to input the number of balls they want to buy and also input those ball's radius. Once the input has been prompted, print out their volumes and surface areas.
Here is code:
import java.text.DecimalFormat;
import java.util.Scanner;
public class VolAndSurA {
public static void main(String[] args) {
DecimalFormat df = new DecimalFormat("####0.00"); // round upto 2
decimal places
int count;
double pi = 3.14;
Scanner s = new Scanner(System.in);
System.out.print("Enter number of balls : ");
count = s.nextInt();
float[] r = new float[count];
double[] area = new double[count];
double[] volume = new double[count];
for (int i = 0; i < count; i++) {
System.out.print("Enter the radius of sphere:" + (i + 1) + "#
");
r[i] = s.nextFloat();
area[i] = 3 * pi * r[i] * r[i];
volume[i] = 1.333 * pi * r[i] * r[i] * r[i];
}
System.out.println("");
for (int i = 0; i < count; i++) {
System.out.println("Surface Area of sphere of radius : " + r[i] + "
is : " + df.format(area[i]));
System.out.println("Volume of sphere of radius : " + r[i] + " is :
" + df.format(volume[i]));
System.out.println("");
}
}
}
Output:

Write a java code prompting the user to input the number of balls they want to...
(java) Write a While loop that prompts the user for only even numbers. Keep prompting the user to enter even numbers until the user enters an odd number. After the loop ends, print the sum of the numbers. Do not include that last odd number. You should not store the numbers in an array, just keep track of the sum. Make sure to use a break statement in your code. You may assume that a java.util.Scanner object named input has...
write the c++ code that keeps prompting (10 times) the user to enter an integer. the code print out the product of all the the integers.
Java Write code for the problem: The user enters exactly 5 scores. Use a for loop to input the scores and count the number of scores that are greater or equal to 80. Print the result after all 5 scores have been entered.
java programming!!!
Write the code fragment that will do the following: • Ask the user how many numbers they want to enter • Declare and instantiate an array of doubles with as many elements as the number entered by the user • Write one 'for' loop to fill the array with data from the user • Write a second 'for' loop to calculate the sum of all of the numbers in the array • Print the calculated sum Note: Write...
I need this code in Java! Start by read in a number from the user that is in the range 1-200. If the user inputs a number out of that range, print out: Invalid number, and end the program. Next, If a number is divisible by 3, print Fizz instead If a number is divisible by 5, print Buzz instead If a number is divisible by both 3 and 5, print out FizzBuzz If a number is none of the...
In python Prompt user to input the number of the month they were born. Using a while loop, continue prompting for the month until the user inputs a valid month number. Figure out the number of days in the month the user entered. Then prompt the user to input the day they were born. Using a while loop, continue prompting until they input a day that is within the range of the number of days in their month. Assume 28...
Write a Java application allowing user to input a Decimal number and output a Binary number?
Write a JAVA application allowing user to input a Decimal number and output a Binary number.
Im lost I need help seriously
Write a javascript that asks the user to input a number. The number is then passed into a function you write that contains a loop. The loop will loop the number you passed into the function and print out the word "CSU" that many times. For instance, if l entered 3, the function would print out "CSU CSU CSU". (20 points) 5.
Write a javascript that asks the user to input a number. The...
How would I write code in Java, where the user inputs a binary number and the system reads the input and outputs if there was an even or odd number of 1s typed. For example, if I typed 10101 it should output as odd. and if I typed 11011 it should output as even.