Results 1 to 2 of 2
  1. #1
    Hatred [BOT]'s Avatar
    Join Date
    Oct 2012
    Gender
    female
    Location
    Konoha
    Posts
    351
    Reputation
    10
    Thanks
    90
    My Mood
    In Love

    Can anyone help me with this?

    I only have 1 problem in my code,

    Code:
    import javax.swing.JOptionPane;
    import java.util.Scanner;
    
    public class FLABWORK3_ABUEL
    {
      static Scanner Scan = new Scanner (System.in);
      public static void main(String[]  args)
      {
    	  String choice;
    	  String num1;
    	  String string;
    	  String Inverse;
    	  
    	  int choicee, num2, response, length;
    	  double squareroot;
    	  
    	  Object[] options = {"Yes", "No"};
    	  
    	  do {
    		  choice = JOptionPane.showInputDialog("Main Menu" + 
    	  "\n 1. Square of a number" +
    	  "\n 2. Square root a number" +
    	  "\n 3. Cube of a number" +
    	  "\n 4. Length of number" +
    	  "\n 5. Inverse of a string");
    		  
    		  choicee = Integer.parseInt(choice);
    		  
    		  while (choicee > 5)
    		  {
    			  choice = JOptionPane.showInputDialog("Enter only 1-5!");
    		  }
    		  
    		  if (choicee == 1)
    		  {
    			num1 = JOptionPane.showInputDialog("Enter an number.");
    			num2 = Integer.parseInt(num1);
    			num2 = num2*num2 ;
    			JOptionPane.showMessageDialog(null, "The square of the number: " + num2);
    			
    		} else if (choicee == 2)
    		{
    			num1 = JOptionPane.showInputDialog("Enter a number.");
    			squareroot = Integer.parseInt(num1);
    			squareroot = Math.sqrt(squareroot);
    			JOptionPane.showMessageDialog(null, "Square root is: " + squareroot);
    			
    		} else if (choicee == 3)
    		{
    			num1 = JOptionPane.showInputDialog("Enter a number.");
    			num2 = Integer.parseInt(num1);
    			num2 = num2*(num2*num2);
    			JOptionPane.showMessageDialog(null, "The cube is: " + num2);
    			
    		} else if (choicee == 4) 
    		{
    			string = JOptionPane.showInputDialog("Enter a sentence or a word.");
    			length = string.length();
    			JOptionPane.showMessageDialog(null, "The length :  " + "\n" + length + "\n\n" +
    			  "is:" + string);
    			
    		}
    		else if (choicee == 5) {
    			string = JOptionPane.showInputDialog("Enter a word.");
    			length = string.length();
    			for (int i = length - 1; i >= 0; i--)
    				  Inverse = Inverse + string.charAt(i);
    			
    			response = JOptionPane.showInputDialog(null,
    					  "Would you like to try again?",
    					  JOptionPane.YES_NO_OPTION,
    					  JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
    		}
    	  }
    	  while (response == JOptionPane.YES_OPTION);
      }
    }
    The error is
    Last edited by Hatred [BOT]; 12-03-2014 at 03:34 AM.

  2. #2
    Cosmo_'s Avatar
    Join Date
    Oct 2014
    Gender
    male
    Location
    Los Angeles
    Posts
    126
    Reputation
    13
    Thanks
    19
    My Mood
    Sleepy
    You're passing int too many arguments to the showinputdialog function

Similar Threads

  1. [Help Request] [Help Request] can anyone help me with this please :)
    By imorata89 in forum WarRock Help
    Replies: 2
    Last Post: 10-27-2013, 05:06 PM
  2. can anyone help me with this problem
    By getoutofmyhouse in forum CrossFire Help
    Replies: 1
    Last Post: 05-31-2013, 05:30 PM
  3. Can anyone help me with this?
    By BoomDokz in forum Warface Discussions & Help
    Replies: 4
    Last Post: 03-11-2013, 08:24 PM
  4. [Help Request] can anyone help me make this mod? for cleric
    By ariefariq2 in forum Dragon Nest Help
    Replies: 3
    Last Post: 09-23-2011, 11:07 AM
  5. Can Anyone Help Me With This Please Read
    By tepa51019 in forum Combat Arms Help
    Replies: 25
    Last Post: 03-01-2011, 11:39 PM