Deliverables: Place your file MidtermPartsAB.docx, and your folders MidtermPartC and MidtermPartD in a parent folder named TakehomeMidterm-Smith (replace Smith by your last name), then zip up the folder to produce TakehomeMidterm-Smith.zip and submit it on the D2L site.
Part A: Multiple Choice Questions. 3 points each. For each question, give an optional reason. 2 points for reason, 1 point for correct answer. If your answer is correct, the reason will not be considered. Create a folder named MidtermPartsAB.docx that contains your answers for Parts A and B.
amt = 2500
tax = 0.05 * amt
print "Total price = $#{amt + tax}.\n"
a.$2250
b.$2500
c.$2550
d.$2625
t = Time.now u = "elephant" if u.length == 7 len = "medium" elsif u.length == 8 len = "large" elsif u.length == 9 len = "jumbo" end w = t.day.to_s + len print wa. 6medium b. 6large c. 8medium d. 9large e. 10jumbo
-------- Controller Code -------- def page1 x = 5 + rand 3 end -------- View Code -------------- <%= x + 1 %>a. 0, 1, 2 b. 0, 1, 2, 3 c. 5, 6, 7, 8 d. 6, 7, 8
Part B. Short Essay. 10 points.
Part C. Create Scaffold Project. 15 points.
| AthleteName | Event | Country | MedalType | EventDate |
|---|---|---|---|---|
| Ryan Lochte | Men's 200m IM | USA | Gold | July 7 |
| Elizabeth Armitstead | Women's Road Cycling | Great Britain | Silver | July 6 |
| Yu Dan | Women's 10m Air Rifle | China | Bronze | July 6 |
Part D. Find the Errors. 15 points.
----- View code in app/views/show_date_time/display.html.erb ----------------------- <p>Date and Time: <%= @datetime %><br> <%= image_tag @timeimg, :class => "img" %> <p>Month: <%= @monthname %><br /> <% image-tag @monthimg, :class = "img" %></p> ----- Layout code in app/views/layouts/application.html.erb ------------------------ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title><%= @title %> <%= stylesheet_tag "application" %> <body> <h2><%= @title %></h2> yield </body> </html> ----- Controller code in app/views/show_date_time_controller/display.html.erb ------ class ShowDateTimeController < ApplicationController def display
@title = "Takehome Midterm -- Show Date and Time"
t = Time.now
@date_time = t
if t.hour >= 6 && t.hour <= 18
@timeimg = "sun.png"
else
@timeimg = "moon.jpg"
end
if t.mon == 1
@monthname = "January"
@monthimg = "jan.jpg'
elsif t.mon = 2
@monthname = "February"
@monthimg = "feb.jpg"
elsif t.mon == 3
@monthname = "March"
@monthimg = "mar.jpg"
elseif t.mon == 4
@monthname = "April"
@monthimg = "apr.jpg"
elsif t.mon == 5
@monthname = "May"
@monthimg = "may.jpg"
elsif t.mon == 6
@monthname = "June"
@monthimg = "jun.jpg"
elsif t.mon == 7
@monthname = "July"
@monthimg = "jul.jpg"
elsif t.mon == 8
@monthname = "August"
@monthimg = "aug.jpg"
elsif t.mon == 9
@monthname = "September"
@monthimg = "sep.jpg"
elsif t.mon == 10
@monthname = "October"
@monthimg = "oct.jpg"
elsif t.mon == 11
@monthname = "November"
@monthimg = "nov.jpg"
elsif t.mon == 12
@monthname = "December"
@monthimg = "dec.jpg"
end
end
----- Stylesheet code in assets/stylesheets/application.html.erb -------------------
/*
*= require_self
*= require_tree .
*/
body { font-family; Helvetica:
font-size: 110%;
text-color: navy;
background_color: lightblue;
.img { width: 200px; }