×

### Let's log you in.

or

Don't have a StudySoup account? Create one here!

×

### Create a StudySoup account

#### Be part of our community, it's free to join!

or

##### By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

by: awright

34

0

4

# ECE 118 Notes ECE 118

awright
UM
GPA 3.9

### Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

×
Unlock Preview

### Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

## About this Document

Notes from January
COURSE
Intro to Programming Languages
PROF.
Kubat
TYPE
Class Notes
PAGES
4
WORDS
KARMA
25 ?

## Popular in Computer Science and Engineering

This 4 page Class Notes was uploaded by awright on Sunday February 28, 2016. The Class Notes belongs to ECE 118 at University of Miami taught by Kubat in Fall 2015. Since its upload, it has received 34 views. For similar materials see Intro to Programming Languages in Computer Science and Engineering at University of Miami.

×

## Reviews for ECE 118 Notes

×

×

### What is Karma?

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 02/28/16
1.25.2016 Notes Convert Kilometers to Miles #include "library.h" double dist_in_miles(double const kilometers) { double const miles = kilometers * 0.624; return(miles); } void main() { double const x = 2; double const k = dist_in_miles(x); print(x);print(" kilometers convert to ");print(k);print(" miles."); new_line(); } Use double so that the answer isn’t rounded. Use return because you want to get an answer back. /*~~~*\ Comment that ignores everything between the /* and the *\ start_shape Tells the computer where a shape begins note_position() Notes where shape continues at each corner fill_shape() Fills the shape with whatever the pen color is set as Drawing Multiple Squares #include "library.h" void draw_square(int const x, int const y, int const side, int const c) { set_pen_color(c); set_heading_degrees(90); move_to(x,y); start_shape(); draw_distance(side); note_position(); turn_right_by_degrees(90); draw_distance(side); note_position(); turn_right_by_degrees(90); draw_distance(side); note_position(); turn_right_by_degrees(90); draw_distance(side); note_position(); fill_shape(); } void draw_three_squares(int const x, int const y, int const side, int const c) { draw_square(x,y,side,c); draw_square(2*x,y,side,c); draw_square(3*x,y,side,c); } void main() { make_window(500, 400); int const x = 100; int const y = 100; int const side = 80; draw_three_squares(x,y,side,color::blue); } Calculating the Average of Two Numbers #include "library.h" double average(double const x, double const y) { double const average = (x + y) / 2; return(average); } void main() { make_window(500, 400); double const x = 10; double const y = 20; double const result = average(x,y); print("The average of ");print(x);print(" and ");print(y); print(" is "); print(result); new_line(); } Ensure that you use double to avoid integer division and you can get the correct answer including any decimals. American Flag Code Saved Here Just In Case #include "library.h" void draw_star(int const x, int const y, int const side, int const c) { //draws one star set_pen_color(c); set_pen_width(1); set_heading_degrees(90); move_to(x,y); start_shape(); draw_distance(side); note_position(); turn_left_by_degrees(72); draw_distance(side); note_position(); turn_right_by_degrees(144); draw_distance(side); note_position(); turn_left_by_degrees(72); draw_distance(side); note_position(); turn_right_by_degrees(144); draw_distance(side); note_position(); turn_left_by_degrees(72); draw_distance(side); note_position(); turn_right_by_degrees(144); draw_distance(side); note_position(); turn_left_by_degrees(72); draw_distance(side); note_position(); turn_right_by_degrees(144); draw_distance(side); note_position(); turn_left_by_degrees(72); draw_distance(side); note_position(); fill_shape(); } void row_of_six_stars (double const x, double const y, int const L) { //draws six stars in a row int const W = L*.526; int const side = W * .111 * .2; draw_star(x+((L*.4*.167)/2), y+((W*.526*.111)/2), side, color::white); draw_star(x+((L*.4*.16)+(L*.4*.167)/2), y+((W*.526*.111)/2), side, color::white); draw_star(x+(2*(L*.4*.16)+(L*.4*.167)/2), y+((W*.526*.111)/2), side, color::white); draw_star(x+(3*(L*.4*.16)+(L*.4*.167)/2), y+((W*.526*.111)/2), side, color::white); draw_star(x+(4*(L*.4*.16)+(L*.4*.167)/2), y+((W*.526*.111)/2), side, color::white); draw_star(x+(5*(L*.4*.16)+(L*.4*.167)/2), y+((W*.526*.111)/2), side, color::white); } void row_of_five_stars (double const x, double const y, int const L) { //draws five stars in a row int const W = L*.526; int const side = W * .111 * .2; draw_star(x+(L*.4*.16), y+((W*.54*.111)), side, color::white); draw_star(x+(2*(L*.4*.16)), y+((W*.54*.111)), side, color::white); draw_star(x+(3*(L*.4*.16)), y+((W*.54*.111)), side, color::white); draw_star(x+(4*(L*.4*.16)), y+((W*.54*.111)), side, color::white); draw_star(x+(5*(L*.4*.16)), y+((W*.54*.111)), side, color::white); } void star_box (double const x, double const y, int const L) { //creates the whole blue section of the flag int const W = L*.526; set_pen_color(color::blue); fill_rectangle(x, y, L*.4, L*.283); int const WW = (W*.54*.11)/2; row_of_six_stars(x, y, L); row_of_five_stars(x, y+(WW), L); row_of_six_stars(x, y+(2*(W*.54*.11)), L); row_of_five_stars(x, y+(2.5*(W*.54*.11)), L); row_of_six_stars(x, y+(4*(W*.54*.11)), L); row_of_five_stars(x, y+(4.5*(W*.54*.11)), L); row_of_six_stars(x, y+(6*(W*.54*.11)), L); row_of_five_stars(x, y+(6.5*(W*.54*.11)), L); row_of_six_stars(x, y+(8*(W*.54*.11)), L); } void stripes (double const x, double const y, int const L) { //creates the seven red and white stripes to the right of the blue box int const W = L*.526; set_pen_color(color::red); fill_rectangle(x+L*.4, y, L-(L*.4), L*.04); set_pen_color(color::white); fill_rectangle(x+L*.4, y+L*.04, L-(L*.4), L*.08); set_pen_color(color::red); fill_rectangle(x+L*.4, y+L*.08, L-(L*.4), L*.12); set_pen_color(color::white); fill_rectangle(x+L*.4, y+L*.12, L-(L*.4), L*.16); set_pen_color(color::red); fill_rectangle(x+L*.4, y+L*.16, L-(L*.4), L*.20); set_pen_color(color::white); fill_rectangle(x+L*.4, y+L*.20, L-(L*.4), L*.24); set_pen_color(color::red); fill_rectangle(x+L*.4, y+L*.24, L-(L*.4), L*.283); set_pen_color(color::white); fill_rectangle(x+L*.4, y+L*.283, L-(L*.4), L*.32); set_pen_color(color::red); fill_rectangle(x*1.0, y+L*.32, L*1.0, L*.36); set_pen_color(color::white); fill_rectangle(x*1.0, y+L*.36, L*1.0, L*.40); set_pen_color(color::red); fill_rectangle(x*1.0, y+L*.40, L*1.0, L*.44); set_pen_color(color::white); fill_rectangle(x*1.0, y+L*.44, L*1.0, L*.48); set_pen_color(color::red); fill_rectangle(x*1.0, y+L*.48, L*1.0, L*.52); set_pen_color(color::white); fill_rectangle(x*1.0, y+L*.52, L*1.0, L*.56); } void draw_flag(double const x, double const y, int const L) { int const W = L*.526; star_box(x, y, L); stripes(x, y, L); } void main() { make_window(800, 800); int const x = 0; int const y = 0; int const L = 500; draw_flag(x, y, L); }

×

×

### BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.

×

### You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

Steve Martinelli UC Los Angeles

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Kyle Maynard Purdue

#### "When you're taking detailed notes and trying to help everyone else out in the class, it really helps you learn and understand the material...plus I made \$280 on my first study guide!"

Steve Martinelli UC Los Angeles

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Parker Thompson 500 Startups

#### "It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!
×

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.