Time SpringBreak = new Time(1999,3,19,17,0,0);
Employee peon = new Employee("Sam Smith", 28000);
Line l = new Line(new Point(0,0),new Point(1,2));
String s = "the fun begins"; String t = "now"; String m = "later"; System.out.print(s + m+" or"); System.out.println(t + s);
Output:
the fun beginslater ornowthe fun begins |
String s = "123,457"; int n = s.length(); System.out.println(s.substring(n-4,n);
Output:
,457 |
int choice = 3; boolean valid = true; if (choice == 1) { System.out.println("You selected 1"); valid = true; } else if (choice == 2) { System.out.println("You selected 2"); valid = true; } else { System.out.println("Your choice is not valid"); valid = false; }
Output:
Your choice is not valid |
import ccj.*; public class Exam {public static void main(String[] args) { int A = 105; int B = A/60; System.out.println(""+(A+B)); } }
Output:
106 |
import ccj.*; public class Example { public static void main(String[] args) { int x = 16; if ((x % 2 == 0) && (x % 3 == 0)) System.out.println("The value of x is divisible by 6"); else System.out.println("The value of x is not a multiple of 6"); } }
Output:
The value of x is not a multiple of 6 |
import ccj.*; public class MysteryApplet1 extends GraphicsApplet {public void run() {Point p1 = new Point(-3,4); Point p2 = new Point(3,4); Line line1 = new Line(p1,p2); Circle c = new Circle(new Point(0,4),3); c.draw(); line1.draw(); } }Output:
import ccj.*; public class MysteryApplet extends GraphicsApplet { public void run() { Point p1 = new Point(-5,-5); Point p2 = new Point(5,5); Line line1 = new Line(p1, p2); line1.draw(); line1.move(3,3); line1.draw(); } }Output:
Answer the following question based on the approach that you selected.
Justify your answer in terms of your chosen approach.
In the Cuckoo's Egg Bob Morris (Sr.) was the head of the NSA and his son Robert T. Morris (Jr.) was responsible for writing a virus that brought the internet to a standstill. Was Bob Morris (Sr.) ethically bound to turn in his son?
import ccj.*; public class Cylinder extends GraphicsApplet {public void run() { Point origin = new Point(0,0); int radius = 3; //CROSS OUT THIS and add: int radius = 6; int height = 4; //CROSS OUT THIS and add: int height = 8; Circle bottom = new Circle(origin,radius); bottom.draw(); Point p1 = new Point(-radius,0); Point p2 = new Point(radius,0); Point p3 = (Point)p1.clone(); Point p4 = (Point)p2.clone(); p3.move(0,height); p4.move(0,height); Line l1 = new Line(p1,p3); Line l2 = new Line(p2,p4); l1.draw(); l2.draw(); bottom.move(0,height); bottom.draw(); } }
import ccj.* public class Commas { public static void main(String[] args) { System.out.print("Enter a 7 digit number:"); int inNum = Console.in.readWord(); String outNum = inNum.substring(0,1) + "," + inNum.substring(1,4) + "," + inNum.substring(4,7); System.out.print(outNum); } } //Can also be done using integers and % and /