So i'm making a program which basically works out tickets sold for an event/events. I have at the moment got an external text file which is linked to my code, the code takes the numbers (which are the amount of tickets someone should of sold for an event) and then i want the user to input using a dialog box how many tickets they have sold. Using if statements i then want the output to be either.. ''Well done you have sold enough tickets'' or ''You should really of sold more tickets'' something like that. This is what i have so far...
import java.util.*;
import java.io.*;
import javax.swing.JOptionPane;
public class ticketjava
{
public static void main(String[] args) throws FileNotFoundException
{
Scanner inFile = new Scanner(new FileReader("C:\\TicketGoals.txt"));
double minimumAmount;
double goodAmount;
minimumAmount = inFile.nextDouble();
goodAmount = inFile.nextDouble();
String yourTickets;
yourTickets = JOptionPane.showInputDialog("Enter your tickets sold:");
if (yourTickets > minimumAmount)
JOptionPane.showInputDialog(null, "Well done you have sold enough tickets", JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
inFile.close();
}
}
As you can see my if statement is nowhere near where it should be as i am really struggling how to order it all out, any help will be much appreciated thanks! I am really struggling with my if statements
yourTicketsand can>be used with that type?yourTicketsis aStringand so can't be used with the>operator. You need to convert the string to some numeric type.