Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.20 KB | None | 0 0
  1. package javaapplication1;
  2. import javax.swing.*;
  3.  
  4. public class JavaApplication1 {
  5.     public static void main(String[] args) {
  6.      double circ,dia,answer1;
  7.      String answer;
  8.       answer = JOptionPane.showInputDialog("What do you want to compute: 'Circumference' or 'Diameter'");
  9.       {
  10.       if(answer.equalsIgnoreCase("circumference")||(answer.equalsIgnoreCase("circ"))){
  11.           do{
  12.               dia = Double.parseDouble(JOptionPane.showInputDialog("Enter value for Diameter"));
  13.           answer1  = dia*Math.PI;
  14.           JOptionPane.showMessageDialog(null, "The Circumference of the circle is: "+answer1);
  15.          
  16.          int option = JOptionPane.showConfirmDialog(null, "Do you want to compute more?", "Choose", JOptionPane.YES_NO_OPTION);
  17.           if(option == JOptionPane.YES_OPTION){
  18.              answer = JOptionPane.showInputDialog("What do you want to compute: 'Circumference' or 'Diameter'");  
  19.           }
  20.           if (option == JOptionPane.NO_OPTION){
  21.              
  22.               JOptionPane.showMessageDialog(null, "All your computed answers are: "+answer1);
  23.               return;
  24.           }
  25.           }
  26.           while(answer.equalsIgnoreCase("circumference")||(answer.equalsIgnoreCase("Circ")));
  27.         }
  28.      if(answer.equalsIgnoreCase("Diameter")||(answer.equalsIgnoreCase("Dia"))){
  29.          do{
  30.              circ = Double.parseDouble(JOptionPane.showInputDialog("Enter value for Circumference"));
  31.              answer1 =  circ/Math.PI;
  32.              JOptionPane.showMessageDialog(null, "The Diameter of the circles is: "+answer1);
  33.              int option = JOptionPane.showConfirmDialog(null, "Do you want to compute more?","Choose", JOptionPane.YES_NO_OPTION);
  34.              if(option == JOptionPane.YES_OPTION){
  35.                 answer = JOptionPane.showInputDialog("What do you want to compute: 'Circumference' or 'Diameter'");
  36.              }
  37.              if (option == JOptionPane.NO_OPTION){
  38.                
  39.               JOptionPane.showMessageDialog(null, "All your computed answers are: "+answer1);
  40.               return;
  41.           }
  42.          }
  43.          while(answer.equalsIgnoreCase("Diameter")||(answer.equalsIgnoreCase("dia")));
  44.          }
  45.      
  46.      }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement