Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Just press ctrl+f and type in #.#.#
- ---------------------------
- 3.1.4
- /* This program should print out your
- * name, and a hobby you have */
- function start(){
- println("My name is ");
- println("I like to play sports");
- }
- // Sample output:
- //
- // My name is Jeremy
- // I like to juggle
- //
- ---------------------------
- 3.2.4
- var time = "";
- var timeOfDay = "";
- function start(){
- time = "8.";
- timeOfDay = "morning, I wake up at ";
- println("In the " + timeOfDay + time);
- // Evening
- time = "12.";
- timeOfDay = "afternoon, I eat lunch at ";
- println("In the " + timeOfDay + time);
- // Afternoon
- time = "11.";
- timeOfDay = "evening, I go to bed at ";
- println("In the " + timeOfDay + time);
- }
- ---------------------------
- 3.3.4
- function start(){
- var name = readLine("Name?");
- println("Hi " + name);
- var time = readInt("Time?");
- println("I will meet you at " + time);
- }
- ---------------------------
- 3.4.6
- //Declare a constant here to represent the cost of a tshirt
- var COST_OF_SHIRT = 20;
- // Starting function for the whole program
- function start(){
- var AMOUNT_OF_SHIRT = readInt("How Many Shirts: ");
- var TOTAL_COST = println("The total cost is " +COST_OF_SHIRT * AMOUNT_OF_SHIRT);
- }
- ---------------------------
- 3.4.7
- // Variables
- var hour = 2;
- // Starting function.
- function start(){
- var minutes = readFloat("Minutes: ");
- var mile = readInt("Miles: ");
- var mph = minutes*hour;
- var mphPrint = println("You ran " + mph + " M/PH");
- }
- ---------------------------
- 3.5.7
- /* This program should draw the Netherlands flag. The
- * top third of the canvas is red, the middle third
- * is white, and the bottom third is blue. */
- function start(){
- redRectangle();
- blueRectangle();
- whiteRectangle();
- }
- // Red Rectangle
- function redRectangle() {
- var rectRed = new Rectangle(400, 160);
- rectRed.setColor(Color.red);
- add(rectRed);
- }
- // Blue Rectangle
- function blueRectangle() {
- var rectBlue = new Rectangle(400, 160);
- rectBlue.setPosition(0, 320);
- rectBlue.setColor(Color.blue);
- add(rectBlue);
- }
- // White Rectangle
- function whiteRectangle() {
- var rectWhite = new Rectangle(400, 160);
- rectWhite.setPosition(0, 160);
- rectWhite.setColor(Color.white);
- add(rectWhite);
- }
- ---------------------------
- 3.5.8
- /* Constants representing the radius of the top, middle,
- * and bottom snowball. */
- var BOTTOM_RADIUS = 100;
- var MID_RADIUS = 60;
- var TOP_RADIUS = 30;
- // The starting function (Runs the entire program.)
- function start(){
- snowmanHead();
- snowmanMiddle();
- snowmanBottom();
- }
- // The head of the snowman
- function snowmanHead() {
- var snowHead = new Circle(TOP_RADIUS);
- snowHead.setPosition(200, 100);
- snowHead.setColor(Color.gray);
- add(snowHead);
- }
- // The middle of the snowman
- function snowmanMiddle() {
- var snowMid = new Circle(MID_RADIUS);
- snowMid.setPosition(200, 190);
- snowMid.setColor(Color.gray);
- add(snowMid);
- }
- // The bottom of the snowman
- function snowmanBottom() {
- var snowBottom = new Circle(BOTTOM_RADIUS);
- snowBottom.setPosition(200, 350);
- snowBottom.setColor(Color.gray);
- add(snowBottom);
- }
- ---------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement