Show Menu
Cheatography

Adv Integrated Software Dev - Quiz1 Cheat Sheet (DRAFT) by

Adv Integrated Software Dev - Quiz1

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Chap 01: Creating Java programs

System.ou­t.p­rin­t("Hello World");
System.ou­t.p­rin­tln­("CSIS 2175");
System.ou­t.p­rin­tln­(St­rin­g.f­orm­at(­"dd is %.2f, %d", dd , 567));
System.ou­t.p­rin­tf(­"d is %.2f", dd);
GUI -> module­-in­fo.java : requires java.d­esktop;

Chap 02: GUI actions

int selection = JOptionPane.showConfirmDialog(null, 
"Would you like to continue?",
"user choice",
JOptionPane.YES_NO_OPTION,
JOptionPane.PLAIN_MESSAGE
);

JOptionPane.showMessageDialog(null, 
"User selected " + selection
);

Chap 02: GUI actions

String n= JOptionPane.showInputDialog(
null,
"Enter your name"
);
String strHours = JOptionPane.showInputDialog(
null,
"Enter hours worked","Hours entered",
JOptionPane.QUESTION_MESSAGE
);
int hours = Integer.parseInt(strHours);

Chap 02: User Input

Scanner input = new Scanner(System.in);
System.out.println("Enter your age");
int age = input.nextInt();
System.out.println("Enter score");
int score = input.nextInt();

//to get rid of enter key		
input.nextLine();
		
System.out.println("Enter your name");
String name = input.nextLine();
System.out.println(
"Hello " + name + " age is " + 
age + " score " + score
);