Coding Flashcards
Import
import javax.swing.*;
Class
public class ________
{
}
Main Method
public static void main (String [] args)
{
}
System.out.println(____);
Allows the user to input
____ = JOptionPane.showInputDialog(“_____”);
Variable WORDS
String _____ = “____”;
Variable INTEGER
int ______ = _______;
Allows users to input integer
int ____ = Integer.parseInt (JOptionPane.showInputDialog (“________”));
Variable REAL NUMBER
double _______ = _______;
Allows users to input real number
double ______ = Double.parseDouble(JOptionPane.showInputDialog(“_____”));
Addition
+
Subtraction
-
Multiplication
*
Division
/
String -> int
String a = “______”;
int i = Integer.parseInt(a);
int -> double
int i = ____;
double d = i;
char -> int
char c = ‘___’;
int i = c ;
int -> String
int i = ___;
String num = i + “”;
String -> char
String name = “___”;
char c = name.charAt(___);
char -> double
char r = ‘___’;
int i = (int) r;
double d = i;
Give char value for what the user inputs
char ____ = JOptionPane.showInputDialog(“___”).charAt(__);
Prints specific letters from words in char
System.out.println(word___.charAt(___));
If statement numbers & true and false
if (ask == true)
{
}
If (ask == false)
{
}
Boolean
boolean ask = Boolean.parseBoolean(JOptionPane.showInputDialog(“_______”));
Incrementing
int num = _____;
++num;
Decrementing
int num = ____;
- -num;
Modulus number
int/double num = ______.parse____(JOptionPane.showInputDialog(“Enter a number”));
if (num%2 == 0)
{
______
}
if (num%2 == 1)
{
_____
}
Print char for whole word
System.out.println(word___.substring(__,__));
if statement words
if (_____.equals(_____))
{
_____
}
if (_____.equals(____))
{
____
}