Results 1 to 3 of 3
  1. #1
    Anseki's Avatar
    Anseki is offline Member
    Join Date
    Oct 2008
    Location
    Philippines
    Posts
    4
    Rep Power
    0

    Question need help..it seems it has an error...

    here is the program I'm doing...

    import javax.swing.*;
    public class adasf
    {
    public static void main (String[]args)
    {
    int km, a, fkm;
    double p = 8.50, dp = 7.00, fp;
    String msg;
    msg = JOptionPane.showMessageDialog(null, "This simple program is based on the idea of the Jeepney Fare Matrix: " , "FARE" , JOptionPane.INFORMATION_MESSAGE);
    km = Integer.parseInt(JOptionPane.showInputDialog("Plea se Enter The Kilometer/s You're About to Travel:"));
    a = JOptionPane.showMessageDialog(null, "Please Choose from the Following: " + "\n[1]Regular" + "\n[2]Student" + "\n[3]Senior" , JOptionPane.INFORMATION_MESSAGE);
    switch (a) {
    case 1:
    if (km>=0&&km<=4)
    {fp = p;
    JOptionPane.showMessageDialog(null, "You're A Regular Passenger" + "The Kilometer/s Riden is: " + km
    + "The Payment is: " + fp , "FARE" , JOptionPane.INFORMATION_MESSAGE);}
    else if (km>4)
    {fkm = km - 4;
    fp = p + (1*fkm);
    JOptionPane.showMessageDialog(null, "You're A Regular Passenger" + "The Kilometer/s Riden is: " + km
    + "The Payment is: " + fp , "FARE" , JOptionPane.INFORMATION_MESSAGE);}
    else
    JOptionPane.showMessageDialog(null, "THERE IS AN ERROR IN THE INPUTED DATA!!!!!", "ERROR!!!!!" , JOptionPane.ERROR_MESSAGE);
    break;
    case 2:
    if (km>=0&&km<=4)
    {fp = dp;
    JOptionPane.showMessageDialog(null, "You're A Regular Passenger" + "The Kilometer/s Riden is: " + km
    + "The Payment is: " + fp , "FARE" , JOptionPane.INFORMATION_MESSAGE);}
    else if (km>4)
    {fkm = km - 4;
    fp = p + (1*fkm);
    JOptionPane.showMessageDialog(null, "You're A Regular Passenger" + "The Kilometer/s Riden is: " + km
    + "The Payment is: " + fp , "FARE" , JOptionPane.INFORMATION_MESSAGE);}
    else
    JOptionPane.showMessageDialog(null, "THERE IS AN ERROR IN THE INPUTED DATA!!!!!", "ERROR!!!!!" , JOptionPane.ERROR_MESSAGE);
    break;
    case 3:
    if (km>=0&&km<=4)
    {fp = dp;
    JOptionPane.showMessageDialog(null, "You're A Regular Passenger" + "The Kilometer/s Riden is: " + km
    + "The Payment is: " + fp , "FARE" , JOptionPane.INFORMATION_MESSAGE);}
    else if (km>4)
    {fkm = km - 4;
    fp = p + (1*fkm);
    JOptionPane.showMessageDialog(null, "You're A Regular Passenger" + "The Kilometer/s Riden is: " + km
    + "The Payment is: " + fp , "FARE" , JOptionPane.INFORMATION_MESSAGE);}
    else
    JOptionPane.showMessageDialog(null, "THERE IS AN ERROR IN THE INPUTED DATA!!!!!", "ERROR!!!!!" , JOptionPane.ERROR_MESSAGE);
    break;
    }
    }
    }


    but it seems to have an error
    here is what it says....:

    C:\Program Files\Xinox Software\JCreator LE\JCreator LE\MyProjects\Anseki\adasf.java:9: incompatible types
    found : void
    required: java.lang.String
    msg = JOptionPane.showMessageDialog(null, "This simple program is based on the idea of the Jeepney Fare Matrix: " , "FARE" , JOptionPane.INFORMATION_MESSAGE);
    ^
    C:\Program Files\Xinox Software\JCreator LE\JCreator LE\MyProjects\Anseki\adasf.java:11: cannot resolve symbol
    symbol : method showMessageDialog (<nulltype>,java.lang.String,int)
    location: class javax.swing.JOptionPane
    a = JOptionPane.showMessageDialog(null, "Please Choose from the Following: " + "\n[1]Regular" + "\n[2]Student" + "\n[3]Senior" , JOptionPane.INFORMATION_MESSAGE);
    ^
    2 errors

    Process completed.

    please help!!!!!!!!:confused::confused::confused::confuse d:

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,247
    Rep Power
    19

    Default

    Read the API for JOptionPane#showMessageDailog(...). It doesn't return a String.

    db

  3. #3
    Anseki's Avatar
    Anseki is offline Member
    Join Date
    Oct 2008
    Location
    Philippines
    Posts
    4
    Rep Power
    0

Similar Threads

  1. error 530 error authentication required
    By rgale in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 05-12-2008, 04:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •