Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import javax.swing.JOptionPane;
- import java.text.DecimalFormat;
- public class areavolume {
- static final float PI = 3.14159265f;
- public static void main(String[] args) {
- Scanner soma = new Scanner(System.in);
- String raio;
- System.out.println("Digite o raio da esfera:");
- raio = soma.nextLine();
- double c = Double.parseDouble(raio);
- double area = (4*c*c*PI);
- double volume = (4*c*c*c*PI/3);
- DecimalFormat df = new DecimalFormat("###,##0.00");
- JOptionPane.showMessageDialog(null,"A area e:\n\n"+(df.format(area)));
- JOptionPane.showMessageDialog(null,"O volume e:\n\n"+(df.format(volume)));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement