new to I.T. need help about the problem analysis ,algorithm design, formatting the output




package gasolinestation;

import javax.swing.JOptionPane;

public class GasolineStation



    {



public static void main(String[] args)



    {



float total, money;

String yesno;

JOptionPane.showMessageDialog(null, "Welcome to Gasoline Station!");

do



    {



String select = JOptionPane.showInputDialog(null, "1 = Diesel .................... $ 39.00\n"

+ "2 = Unleaded .................... $ 49.95\n"

+ "3 = Extreme ................ $ 51.95\n"

+ "4 = Kerosene ................ $ 00.00\n\n"

+ "Enter the number of your choice:");

if("1".equals(select))



    {



String liter = JOptionPane.showInputDialog(null, "How many liters of Diesel?");

total = (float)(39.00*Float.parseFloat(liter));

JOptionPane.showMessageDialog(null, "Total price: $ "+total);

String pera = JOptionPane.showInputDialog(null, "Enter your money!");

money = Float.parseFloat(pera);

if(money>total)



    {



JOptionPane.showMessageDialog(null, "Your change is: $ "+(money-total));



    }



else



    {



JOptionPane.showMessageDialog(null, "Insufficient money!");





    }
    }



else if("2".equals(select))

{

String liter = JOptionPane.showInputDialog(null, "How many liters of Unleaded?");

total = (float)(49.95*Float.parseFloat(liter));

JOptionPane.showMessageDialog(null, "Total price: $ "+total);

String pera = JOptionPane.showInputDialog(null, "Enter your money!");

money = Float.parseFloat(pera);

if(money>total)

{

JOptionPane.showMessageDialog(null, "Your change is: $ "+(money-total));

}

else

{

JOptionPane.showMessageDialog(null, "Insufficient money!");

}

}

else if("3".equals(select))

{

String liter = JOptionPane.showInputDialog(null, "How many liters of Extreme?");

total = (float)(51.95*Float.parseFloat(liter));

JOptionPane.showMessageDialog(null, "Total price: $ "+total);

String pera = JOptionPane.showInputDialog(null, "Enter your money!");

money = Float.parseFloat(pera);

if(money>total)

{

JOptionPane.showMessageDialog(null, "Your change is: $ "+(money-total));

}

else

{

JOptionPane.showMessageDialog(null, "Insufficient money!");

}

}

else if("4".equals(select))

{

String liter = JOptionPane.showInputDialog(null, "How many liters of Kerosene?");

total = (float)(00.00*Float.parseFloat(liter));

JOptionPane.showMessageDialog(null, "Total price: $ "+total);

String pera = JOptionPane.showInputDialog(null, "Enter your money!");

money = Float.parseFloat(pera);

if(money > total)

{

JOptionPane.showMessageDialog(null, "Your change is: $ "+(money-total));

}

else

{

JOptionPane.showMessageDialog(null, "Insufficient money!");

}

}

else

{

JOptionPane.showMessageDialog(null, "Invalid number!");

}

String repeat = JOptionPane.showInputDialog(null, "Would you like to try again? (Y/N): ");

yesno = String.valueOf(repeat);

}

while("Y".equals(yesno) || "y".equals(yesno));

}

}

Inline Code Example Here

my teacher give this a project can you help me guys on this program

Hello neondroid

You have not explained exactly what help you need. Nobody is going to read all that incorrectly-formatted code, then try to guess what your questions are!

so please
1. Explain exactly in detail what you need to know. If you have an error then explain exactly what the error is and post any error messages in full.
2. Re-post your code correctly indented, with the { and } correctly lined up, and all the unecessary blank lines removed, so we can read it.

you may want to work on your indentation as well, it'll make it a lot easier to actually read that code.
if this is code your teacher gave you, then most likely, what you are asking us to do, is your homework. you should find all the information you need in your textbooks and course notes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.