What exactly does this mean?
// The "Chapter6RandomCards" class.
import java.awt.*;
import hsa.Console;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.IOException;
public class RandomCards
{
static Console c; // The output console
public static void main (String[] args) throws IOException
{
c = new Console ();
int card;
// PrintWriter output;
////////
FileOutputStream fis;
////////
try
{
fis = new FileOutputStream ("dice.txt");
//work with the file in here
for (int count = 1 ; count <= 1 ; count++)
{
card = (int) (Math.random () * 5);
// output.println (card);
c.println (card);
}
if (card = 1)
{
c.println ("You rolled an Ace of Spades");
}
if (card = 2)
{
c.println ("You rolled an Ace of Clubs");
}
c.println ("The card you chose is a:");
}
catch (IOException e)
{
// No error message
}
finally
{
// Make sure the resources used are closed
// try { output.close(); } catch ( IOException e ) {}
}
} // main method
} // Chapter6RandomCards class
When I try and executethe program it highlights "if (card = 1)" and "if ( card = 2)"
The error message is: The type of this expression, "int", is not "boolean". What does this mean? The program is simply supposed to generate a single random number, and each different number has a different card assigned to it, with is outputted on the console. How can I fix this error? Thank you.
// The "Chapter6RandomCards" class.
import java.awt.*;
import hsa.Console;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.IOException;
public class RandomCards
{
static Console c; // The output console
public static void main (String[] args) throws IOException
{
c = new Console ();
int card;
// PrintWriter output;
////////
FileOutputStream fis;
////////
try
{
fis = new FileOutputStream ("dice.txt");
//work with the file in here
for (int count = 1 ; count <= 1 ; count++)
{
card = (int) (Math.random () * 5);
// output.println (card);
c.println (card);
}
if (card = 1)
{
c.println ("You rolled an Ace of Spades");
}
if (card = 2)
{
c.println ("You rolled an Ace of Clubs");
}
c.println ("The card you chose is a:");
}
catch (IOException e)
{
// No error message
}
finally
{
// Make sure the resources used are closed
// try { output.close(); } catch ( IOException e ) {}
}
} // main method
} // Chapter6RandomCards class
When I try and executethe program it highlights "if (card = 1)" and "if ( card = 2)"
The error message is: The type of this expression, "int", is not "boolean". What does this mean? The program is simply supposed to generate a single random number, and each different number has a different card assigned to it, with is outputted on the console. How can I fix this error? Thank you.