Tuesday, October 20, 2015

Visual Basic Programming Exercises: Chapter 5 Lists and Loops

5.3 Introduction to Loops: The Do While Loop a posttest loop 
 
40181
 
Given an Integer variable  n that has been initialized to a positive value and, in addition, Integer variables  k and total that have already been declared, use a While loop to compute the sum of the cubes of the first n whole numbers, and store this value in total. Use no variables  other than n, k, and total


k = 0
total = 0
Do While (k <= n)
 total = (total + (k*k*k))
 k += 1
Loop
 
40178
Given an Integer variable  k that has already been declared, use a pretest Do While loop to print a single line consisting of 88 asterisks. Use no variables  other than k

Do While k < 88
    Console.Write("*")
    k+= 1
Loop
 
40179
Given an Integer variable  n that has already been declared and initialized to a positive value, use a pretest Do While loop to print a single line consisting of n asterisks. Use no variables  other than n.
 
 Do While (n > 0)
 Console.Write("*")
 n -= 1
Loop
 
 
40387
 
Write a statement that increments the value of the int variable  total by the value of the int variable  amount. That is, add the value of amount to total and assign the result to total

total += amount
 
40180
Given Integer variables  k and total that have already been declared, use a pretest Do While loop to compute the sum of the squares of the first 50 whole numbers, and store this value in total. Thus your code should put 1*1 + 2*2 + 3*3 +... + 49*49 + 50*50 into total. Use no variables  other than k and total

k = 1
total = 0
Do While (k <= 50)
 total = (total + (k*k))
 k += 1
Loop
 
40379
 
Given an int variable  n that has been initialized to a positive value and, in addition, int variables  k and total that have already been declared, use a while loop to compute the sum of the cubes of the first n counting numbers, and store this value in total. Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total. Use no variables  other than n, k, and total. Do NOT modify n

k = 0
total = 0
Do While (k <= n)
 total = (total + (k*k*k))
 k += 1
Loop



40378
 
Given int variables  k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 counting numbers, and store this value in total. Thus your code should put 1*1 + 2*2 + 3*3 +... + 49*49 + 50*50 into total. Use no variables  other than k and total

k = 1
total = 0
Do While (k <= 50)
 total = (total + (k*k))
 k += 1
Loop
 
 
5.4 The Do Until and For...Next Loops
 
40182
 
Given an Integer variable  k that has already been declared, use a posttest Do While loop to print a single line consisting of 53 asterisks. Use no variables  other than k

Do
    Console.Write("*")
    k+= 1
Loop While k < 53

 
40183
 
Given an int variable  n that has already been declared and initialized to a positive value, use a posttest Do While loop to print a single line consisting of n asterisks. Use no variables  other than n

Do
    Console.Write("*")
    n -= 1
Loop While n > 0

 

40184
 
Given int variables  k and total that have already been declared, use a posttest Do While loop to compute the sum of the squares of the first 50 whole numbers, and store this value in total. Thus your code should put 1*1 + 2*2 + 3*3 +... + 49*49 + 50*50 into total. Use no variables  other than k and total

k = 1
total = 0
Do While (k <= 50)
 total = (total + (k*k))
 k += 1
Loop

 
40174
 
Given an int variable  k that has already been declared, use a for loop to print a single line consisting of 97 asterisks. Use no variables  other than k

For k = 1 To 97
Console.Write("*")
Next

 
40288
  Write a for loop that computes the following sum: 5+10+15+20+...+485+490+495+500. The sum should be placed in a variable  sum that has already been declared and initialized to 0. In addition, there is another variable , num that has also been declared. You must not use any other variables .
 
 sum = 0
For num = 5 to 500 step 5
 sum += num
Next
 
 
40185
 
Given an int variable  n that has been initialized to a positive value and, in addition, int variables  k and total that have already been declared, use a do...while loop to compute the sum of the cubes of the first n whole numbers, and store this value in total. Use no variables  other than n, k, and total

total = 0
For k = 0 to n
 total += k*k*k
Next

 
40385
 
Assume the int variables  i, lo, hi, and result have been declared and that lo and hi have been initialized.
Write a for loop that adds the integers between lo and hi (inclusive), and stores the result in result.
Your code should not change the values of lo and hi. Also, do not declare any additional variables  -- use only i, lo, hi, and result

result = 0
For i = lo To hi
 result += i
Next

 
40374
  Given int variables  k and total that have already been declared, use a for loop to compute the sum of the squares of the first 50 counting numbers, and store this value in total. Thus your code should put 1*1 + 2*2 + 3*3 +... + 49*49 + 50*50 into total. Use no variables  other than k and total.
 
total = 0

For k = 0 To 50

total = total + k*k

Next
 
 
40375
 
Given an int variable  n that has been initialized to a positive value and, in addition, int variables  k and total that have already been declared, use a for loop to compute the sum of the cubes of the first n whole numbers, and store this value in total. Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total. Use no variables  other than n, k, and total

total = 0

For k = 1 to n

total += k*k*k

Next

 
40502
 
Assume the integer variables  counter, low, high, and result have been declared and that low and high have been initialized.
Write a For loop that adds the integers between low and high (inclusive), and stores the result in result.
Your code should not change the values of low and high. Also, do not declare any additional variables  -- use only counter, low, high, and result

result = 0

For counter = low to high

result = result + counter

Next

 
40176
 
Given int variables  k and total that have already been declared, use a for loop to compute the sum of the squares of the first 50 whole numbers, and store this value in total. Thus your code should put 1*1 + 2*2 + 3*3 +... + 49*49 + 50*50 into total. Use no variables  other than k and total

total = 0

For k = 0 to 50

total = total + k*k

Next

 
40177
 
Given an Integer variable  n that has been initialized to a positive value and, in addition, Integer variables  k and total that have already been declared, use a For loop to compute the sum of the cubes of the first n whole numbers, and store this value in total. Use no variables  other than n, k, and total

total = 0

For k = 1 to n

total += k*k*k

Next

 
40187
 
Assume the int variables  i,lo, hi, and result have been declared and that lo and hi have been initialized. Assume further that result has been initialized to the value 0.
Write a for loop that adds the integers between lo and hi (inclusive), and stores the result in result.
Your code should not change the values of lo and hi. Also, do not declare any additional variables  -- use only i,lo, hi, and result

For i = lo To hi

result += i

Next

 
40223
 
Give that two Integer variables , total and amount have been declared, write a loop that reads non-negative values into amount and adds them into total. The loop terminates when a value less than 0 is read into amount. Don't forget to initialize total to 0.
To read a value into amount use a method, getNum() that we provide for you a class named TC:
   amount = TC.getNum();


total = 0
amount = 0

Do

    total += amount

    amount = TC.getNum()

Loop Until (amount < 0) 

Great Ideas for Data Visualization

Sources:
http://www.webdesignerdepot.com/2009/06/50-great-examples-of-data-visualization/

http://www.informationisbeautiful.net/

http://www.visualisingdata.com/

Progressive Design for the Web

Source:
http://www.webdesignerdepot.com/2015/08/progressive-design-for-the-modern-web/

Progressive design for the modern web



Good responsive web design, by its nature, goes unnoticed to those consuming content online. So when someone asks for a new website, they’re often completely unaware of the concept, despite experiencing it on a daily basis. And yet, responsive website design is now acknowledged as standard practice throughout the industry.
Building responsive websites has altered our processes, from creating mockups of complete pages, to building libraries of reusable components and layouts.
layout is content-driven and styles are brand-driven
Recently we were approached by an existing client to responsively redesign their website. We’d previously worked with them using a rigid waterfall process. Moving to an agile workflow, we were able to embrace change at any point in the project.
Throughout the process we adhered to the philosophy that layout is content-driven and styles are brand-driven.

Wire-framing the specifications

Specification documents work great for listing out all the functionality a site is required to have. But is it really what the client needs? It’s very hard to visualize these features in place. Thus the result is that specification documents often turn into bloated wishlists. This doesn’t help the client, designers, or the final website.
Instead of specification documents, we opted to use wire-frames. The first step of the project involved creating wire-frames for every page. This may sound like overkill, but the wire-frames led to early discussions of the content and features for each page. We found that features that we never considered before were added, while many were removed.
Wire-frames gave us a clear, visual representation of how content and functionality should be prioritized on each page. These wire-frames then became a reference point, replacing a specification document.
Key takeaway: producing wire-frames in place of specification documents focuses everyone on the core features and the importance of content.

Auditing

Auditing the wire-frames allows us to form a list of all the common components. Across a single site there will be dozens of small sections on each page that are very similar. These components can be collated into an exhaustive list which will be used later on.
This stage has three main benefits:
  • It flags any discrepancies in the wire-frames. Think of it as proof-reading the wire-frames. Some areas may be different for no real reason. We can tie the whole site together before we start building unnecessary components or layouts.
  • It helps keep all of the front-end code as lean as possible. Planning how the CSS will be structured has become vital on large projects. We want the website to be as fast as possible and structuring the CSS early on helps this.
  • Large websites will involve multiple people at any time, both during development and in the future. Creating maintainable code is important for the project moving forward.
Key takeaway: planning how to approach the front-end development of a project is important to create a maintainable, lean code base.

Pattern libraries

Pattern libraries are a collection of common elements used on a website. By focusing the front-­end development on building components that are not dependent on pages, we can reduce the code overhead and improve consistency.
Using the list of components we collated during the auditing stage, we are able to structure our Sass into a manageable collection of files.

Naming conventions are important

We’ve used pattern libraries on a few projects but have always struggled with naming conventions, particularly the folder structure: where do you put your styles for this music player, in components, or in partials?
Previously, we’d been using terminology such as partials and components to organize our Sass files. While these seem like completely legitimate naming conventions, they are open to interpretation. When there are multiple developers working on a project, leaving the organization of the code base open to interpretation leads to unorganized CSS.
BEM (Block, Element, Modifier), provides us with a common convention to follow, and creates an understanding between front­-end developers. The old way was left to individual developers to come up with class names that were all too high-level to glean any meaning from. Fortunately we were lucky to see Brad Frost speak about his pattern library at the Upfront Conference in Manchester. Pattern Lab lends terminology from chemistry to describe the components that make up the library. Using atoms, molecules and organisms to describe the differences between components on a page helps explain the concept to developers new to the project.

Atoms – the essentials

In nature, atoms are the smallest denomination (unless we delve into quarks and electrons). In web development, atoms are the most basic elements of HTML. To all intents and purposes they don’t do much on their own. These include headings, paragraphs, inputs, buttons, lists…You get the idea.

Molecules – scalable patterns

These are the next layer up. In chemistry, molecules are made up of atoms, and the same applies to the structure of CSS. Molecules are components on the website that use atoms to form them.
A good example of a molecule is a search box. This contain 3 atoms:­ a label, input and button. The molecule layer starts to form some of the elements we can use on the website. It’s important to make all of these molecules scalable. They should be designed with the idea they could be used anywhere on the site. Our ultimate goal to make the CSS as flexible and reusable as possible.

Organisms – collections of patterns

As the name suggests, organisms are groupings of molecules. Some examples of these include a header, footer, or list of products.
If we take the example of a header, this would include a logo, search, and navigation. These were all created as molecules and are combined to form a header organism.

Templates – The glue of a page

This is where the biochemistry analogy ends. As Brad says, “get into language that makes more sense to clients and final output”. Templates are the glue of a website. These combine all of the organisms we’ve created into a layout that could be applied to a page on the website.
An example could be a blog listing. This template would include a header, footer, a list of blog items, and a sidebar. Templates are generally structural, containing only the layout.

Pages – Handling variations

The final section is pages. This is where you can test the templates with real data. Pages are specific instances of a template. This part is important because it allows us to see how successful the atoms, molecules, organisms and templates have been.
It’s inevitable that when building the website, certain scenarios will be missed. The classic example is long titles, or catering for different currencies and languages.
Key takeaway: Naming conventions matter. Layering CSS creates a clean codebase to work from that is as small as possible.

Designing with flexibility in mind

Designing patterns is hard. You can’t design an isolated pattern such as a news item, and expect it to fit with the rest of the page. The way we build websites and the way we design them differ.
Designs are likely to change regardless of whether we get sign-off…Sign-off became an irrelevant step in the process that only put pressure on both sides
We used Photoshop to create mockups of the wire-frames with these styled components in place. Once we were happy with the look and feel of the designs we moved to isolating each component. This allowed us to ensure each component was flexible enough to work anywhere on the website.
We were very conscious to not get sign-off on any design work. Design sign-off creates a barrier where the designer feels pressured to create something that will be set in stone. Designs are likely to change regardless of whether we get sign-off or not. Generally we are happy to accommodate any changes at any point in the project timeline. Sign-off became an irrelevant step in the process that only put pressure on both sides to the detriment of the relationship.

Move from Photoshop to code quickly

Knowing when to move from Photoshop to code is important. This step is much earlier than we were used to for two reasons:
  1. Perfecting layouts in Photoshop is time consuming and ultimately a waste of time. Time perfecting the website is better spent at the end, on the actual code.
  2. It creates a reference point for what the website should look like. The reality is, it will never look identical; but once a client has seen (and perfected) the designs, an expectation is created.
Instead of spending additional time in Photoshop we opted to invest the time in code. If we should perfect anything, it should be the code, the bit that will actually be used and seen by all the website users. For us, Photoshop was a tool for creating a design style that could be used across the website.
Design is much more about collaboration between everyone on the team. Mockups were still a very important part of the process, helping the client to visualize how the site would look. If we were all happy with the general direction of the design, we would move it to code. We rarely spent time going backwards and forwards making amends to Photoshop documents.
Key takeaway: Photoshop is a great tool for creating design concepts. Moving to code as soon as possible is important. Perfect it in code, not Photoshop.

Iterate for better usability

The beauty of this workflow is there are so many places to review and improve the website.
It is important to note that these are loose steps in our project process. If we need something new during the project, we will generally treat it as a standalone, modular component that can be dropped into the website and adopt the design theme of the site.
  • At the wire-framing stage we plan the project
  • At the auditing stage we review and improve the wire-frames
  • At the design stage we mockup a design style
  • At the coding stage we integrate it all together
Each of these steps offers a point where we can review our work so far. It also allows for a fresh set of eyes to see things from a different perspective.
During any of these stages we may find that some parts aren’t working as well as expected. This is okay. In fact it’s good. Catching poor usability early is key for a successful website. Going back and wire-framing these parts of the website will make the project better when it goes live.
Key takeaway: Don’t be scared to go back to the beginning if something needs improving. Catching these early will make the project better when it goes live.

The finish

We spent days working together to ensure every part of the website was finished to a high standard. We tested as many scenarios as possible, ensuring the browsing experience was consistent.
Once the data is in the website we are able to fully test the website. It’s often too easy to set a project live without fully testing. We can check the speed, ease of navigation and most importantly the purchasing flow.
Everyone mentions Apple for being perfectionists but I am sure their first attempts were far from perfect. It takes time and dedication to make those final improvements to give us the products we love today. Using our device lab, that includes most of the popular devices and platforms, we were able to ensure that the experience was the optimized on as many of the latest platforms and screen sizes as possible.

Retrospective

Learning from each project is important so we can continually improve processes that lead to better websites.
This project saw the birth of our own in­-house pattern library that encourages consistency between projects. When working in an agency, we may have dozens of projects currently in development simultaneously. The ability for anyone to work on any project is important.
Creating a base we can all work on will help contribute to this goal.
The performance of the website was only considered towards the end of the project. A successful responsive website needs to be lean and fast. The huge range of devices and their capabilities vary massively from brand new Mac computers to old smartphones. When building a media rich website is can be very hard to manage the performance, especially when retrospectively trying to improve it.
At Upfront Conference in Manchester, we saw Yesenia Perez Cruz speak about considering performance at every stage of a project, including design. In hindsight, this is something we should have implemented. As a team of multiple designers, developers and front-end developers, managing the overall size and performance (particularly the perceived performance) should have been a bigger priority.
Everything on a page has a cost for performance. Prioritizing what is important ensures the website is not only fast, but accessible to more devices. On some older devices, we found that the website crashed not just the browser, but the entire device. Trying to speed up the website retroactively meant we couldn’t make the website as fast as it could have been.
Next time we will make sure performance ingrained into every stage of the process, so it isn’t an afterthought.

mind mapping

Source: http://freemind.sourceforge.net/wiki/index.php/Main_Page

An Example Data visualization


Tuesday, October 13, 2015

Visual Basic Programming Exercise Chapter 4 Making Decisions


Visual Basic Programming Chapter 4: Making Decisions



4.4.

The If...Then....ElseIf Statement


40367

Write an if/else statement that adds 1 to the variable  minors if the variable  age is less than 18, adds 1 to the variable  adults if age is 18 through 64, and adds 1 to the variable  seniors if age is 65 or older. 

If (age < 18) Then
    minors = minors + 1
   
    ElseIf (age < 65) Then
        adults = adults + 1
   
    Else
        seniors = seniors + 1
   
End If


OR


If (age < 18) Then
minors += 1
ElseIf (age < 65) Then
adults += 1
Else
seniors += 1
End If

40368 
 
Write an if/else statement that compares the double variable  pH with 7.0 and makes the following assignments to the bool variables  neutral, base, and acid:
  • false, false, true if pH is less than 7
  • false, true, false if pH is greater than 7
  • true, false, false if pH is equal to 7
If (pH < 7) Then
   
    neutral = false
    base = false
    acid = true
   
Elseif (pH > 7) Then
   
    neutral = false
    base = true
    acid = false
   
Elseif (pH = 7) Then
   
    neutral = true
    base = false
    acid = false
   
End If
 
 
 
41064 
 
 
Online Book Merchants offers premium customers 1 free book with every purchase of 5 or more books and offers 2 free books with every purchase of 8 or more books. It offers regular customers 1 free book with every purchase of 7 or more books, and offers 2 free books with every purchase of 12 or more books.
Write a statement that assigns freeBooks the appropriate value based on the values of the bool variable  isPremiumCustomerand the int variable nbooksPurchased.


41062
 
Write a statement that increments (adds 1 to) one and only one of these five variables : reverseDrivers parkedDrivers slowDrivers safeDrivers speeders.
The variable  speed determines which of the five is incremented as follows:
The statement increments reverseDrivers if speed is less than 0, increments parkedDrivers if speed is less than 1, increments slowDrivers if speed is less than 40, increments safeDrivers if speed is less than or equal to 65, and otherwise increments speeders.


41063
 
Write a statement that compares the values of score1 and score2 and takes the following actions. When score1 exceeds score2, the message "player1 wins" is printed to standard out. When score2 exceeds score1, the message "player2 wins" is printed to standard out. In each case, the variables  player1Wins,, player1Losses, player2Wins, and player2Losses,, are incremented when appropriate.
Finally, in the event of a tie, the message "tie" is printed and the variable  tieCount is incremented.
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Friday, October 9, 2015

Queen Poster

Playing with Illustrator. Created this as a reminder for all women.
10/9/15
I must remember to export PNG files with the correct settings.. usually the file would cut off,

Image Source:
http://www.monahanjewelry.com/blog/

Typeface: Lao Sangam MN

2014 Website

Created this Website to showcase my resume/ porfolio

Pretty sad annamarieflores.com is taken now


Moi - San Diego State University 2013



Bachelor of Applied Arts Emphasis in Multimedia

Mother at work. San Diego County Admnistration Building

Playing with Photoshop

Frida Book Cover


Playing around Photoshop.

Adobe Illustrator Brush Artwork



Playing with different brush strokes 10/09/15

I like the grunge and charcoal

Visual Basic Programming Chapter 3 Variables and Calculations

3.1 Gathering Text Input

41010

Assume you have a text box named textBox. Write some code that inputs the value in the text box into a variable  name and then outputs "Greetings, NAME" to a message box (where NAME is replaced by the value that was input read into the variable .
For example, if the text box originally contained "Rachel" your code would display "Greetings, Rachel" in the message box.


name = textBox.Text
MessageBox.Show("Greetings, " & name)


3.2 Variables and Data Types
 declaration

60105
 Before a variable is used it must be_____
declared
60106
 Which of the following is NOT a legal identifier?
 
outrageouslyAndShockinglyLongRunon
 _42
_
lovePotionNumber9
7thheaven
 
7thheaven
 
60110
 Which is the best identifier for a variable to represent the amount of money your boss pays you each month?
 
notEnough
wages
paymentAmount
monthlyPay
money
 
monthlyPay
 
85016
 
QUESTION 1:  Correct

Of the following variable names, which is the best one for keeping track of whether a patient has a fever or not?
 
temperature
feverTest
hasFever
fever

hasFever

QUESTION 2:  Correct

Of the following variable names, which is the best one for keeping track of whether an integer might be prime or not?
 
divisible
isPrime
mightBePrime
number assignment 
 
mightBePrime 
 
assignment:

40947
Write a statement to set the value of num to 4 (num is a variable  that has already been declared).
num = 4
 
 
40338
 Given an integer variable  drivingAge that has already been declared, write a statement that assigns the value 17 to drivingAge
drivingAge = 17
 
40339
 Given two integer variables  oldRecord and newRecord, write a statement that gives newRecord the same value that oldRecord has.
newRecord = oldRecord
 
40948
 Given two integer variables  num and highest, write a statement that gives highest the same value that num has.
highest = num
 
40349
 Given three already declared int variables , i, j, and temp, write some code that swaps the values i i and j. Use temp to hold the value of i and then assign j's value to i. The original value of i, which was saved in temp, can now be assigned to j
 
temp = i
     i = j
     j = temp
 
40350
 
 Given two int variables , firstPlaceWinner and secondPlaceWinner, write some code that swaps their values.

Declare any additional variables  as necessary, but do not redeclare firstPlaceWinner and secondPlaceWinner
 
 
dim swap as Integer
swap = firstPlaceWinner
     firstPlaceWinner = secondPlaceWinner
secondPlaceWinner = swap
 
 
40351

Given two double variables , bestValue and secondBestValue, write some code that swaps their values. Declare any additional variables  as necessary.

Dim swap As Double
swap = bestValue
bestValue = secondBestValue
secondBestValue = swap
 
 
types and literals:
 60113
Write a long integer literal that has the value thirty-seven  
 37L
 
40038
 
Write a floating point literal corresponding to the value zero.
 0.0D

40039 
 
Write a literal corresponding to the floating point value one-and-a-half
 1.5D

 
40040
 
Write a literal corresponding to the value of the first 6 digits of PI ("three point one four one five nine"). 

3.14159D
 
 
input of variables:
40980
Write an expression that attempts to read a double value from the TextBox textBox and stores it in a Double variable , x, that has already been declared.
 
x = CDbl(textBox.Text)
 
 
output of variables: 


41098

Assume that message is a String variable . Write a statement to display its value in a MessageBoxt.
 MessageBox.Show(message)
 
 
41099 
 Assume that word is a String variable . Write a statement to display the message "Today's Word-Of-The-Day is: " followed by the value of word in a MessageBox. 
 
 MessageBox.Show("Today's Word-Of-The-Day is: " + word)
 
 input and output:


41011 
Assume that name has been declared suitably for storing names (like "Amy", "Fritz" and "Moustafa") Write some code that reads a value from a text box named textBox into name then prints the message "Greetings, NAME!!!" where NAME is replaced the value that was read into name. For example, if your code read in "Hassan" it would print out "Greetings, Hassan!!!".
 
name = textBox.Text

MessageBox.Show("Greetings, " & name & "!!!")
 
 
 3.3 Performing Calculations
 
operations:
40326
Write an expression that computes the sum of the two variables  verbalScore and mathScore (already declared and assigned values). 

verbalScore + mathScore
 
 
40327
Given the variables  taxablePurchases and taxFreePurchases (already declared and assigned values), write an expression corresponding to the total amount purchased. 

taxablePurchases + taxFreePurchases
 
 
40328
Write an expression that computes the difference of the variables  endingTime and startingTime.
 
 endingTime - startingTime
 
40329
 
Given the variables  fullAdmissionPrice and discountAmount (already declared and assigned values), write an expression corresponding to the price of a discount admission. (The variable  discountAmount holds the actual amount discounted, not a percentage.) 

fullAdmissionPrice - discountAmount
 
 
40330
 
Given the variable  pricePerCase, write an expression corresponding to the price of a dozen cases. 

 pricePerCase * 12

40331

Given the variables  costOfBusRental and maxBusRiders, write an expression corresponding to the cost per rider (assuming the bus is full). 

costOfBusRental / maxBusRiders
 
40048
 
You are given two variables , already declared and assigned values, one of type double, named price, containing the price of an order, and the other of type int, named totalNumber, containing the number of orders. Write an expression that calculates the total price for all orders. 

price * totalNumber
 
 
40044
 
Write an expression that computes the sum of two double variables  total1 and total2, which have been already declared and assigned values. 

total1 + total2
 
40045
  Write an expression that computes the difference of two double variables  salesSummer and salesSpring, which have been already declared and assigned values
salesSummer - salesSpring
 
40046 
 
You are given two double variables , already declared and assigned values, named totalWeight, containing the weight of a shipment, and weightOfBox, containing the weight of the box in which a product is shipped. Write an expression that calculates the net weight of the product. 

totalWeight - weightOfBox
 
40047
 
You are given two variables , already declared and assigned values, one of type double, named totalWeight, containing the weight of a shipment, and the other of type int, named quantity, containing the number of items in the shipment. Write an expression that calculates the weight of one item

totalWeight / quantity
 
40905
 
Assume that an int variable  x that has already been declared,.
Write an expression whose value is 1 more than x

x + 1

 
40332
Write an expression that computes the remainder of the variable  principal when divided by the variable  divisor. (Assume both are type int.) 

principal Mod divisor
 
 
40346
Write an expression that evaluates to true if the value of the integer variable  widthOfBox is not evenly divisible by the integer variable  widthOfBook. (Assume that widthOfBook is not zero. Note: evenly divisible means divisible without a non-zero remainder.) 

widthOfBox Mod widthOfBook
 
 
41023
 Assume that price is an integer variable  whose value is the price (in US currency) in cents of an item. Write a statement that prints the value of price in the form "X dollars and Y cents". So, if the value of price was 4321, your code would print "43 dollars and 21 cents". If the value was 501 it would print "5 dollars and 1 cents". If the value was 99 your code would print "0 dollars and 99 cents". 
 
MessageBox.Show((price \ 100) & " dollars and " & (price Mod 100) & " cents")
 
assignments and operations:
 
 
40340
 
Given two integer variables  matricAge and gradAge, write a statement that gives gradAge a value that is 4 more than the value of matricAge

gradAge = matricAge + 4
 
40953
Write a statement to set the value of area to the value of length times the value of width. (The variables  have already been declared and length and width have already been initialized.)
 
area = length * width
 
40949
  Write a statement to set the value of ans equal to the value of num plus 5. (These variables  have already been declared and num has already been initialized.) 
 
ans = num + 5
 
 
40950
Write a statement to set the value of price equal to three times the value of cost. (The variables  have already been declared and cost has already been initialized.)
 
price = 3 * cost
 
40951
Write a statement to add the values of x and y together, storing the result in sum. (The variables  have already been declared and x and y have already been initialized.)
 
sum = x + y
 
40952
Write a statement to subtract tax from gross_pay and assign the result to net_pay . (The variables  have already been declared and gross_pay and tax have already been initialized.)
net_pay = gross_pay - tax
 
40957
Write a statement to find the remainder remdr when num is divided by 5. (The variables  have already been declared and num has already been initialized.)
 
remdr = num mod 5
 
40956
Write a statement to assign to kilos the value of pounds divided by 2.2. (The variables  have already been declared and pounds has already been initialized.)
 
kilos = pounds / 2.2
 
40954
  Write a statement to multiply diameter by 3.14159 and assign the result to circumference. (The variables  have already been declared and diameter has already been initialized.)
 
circumference = diameter * 3.14159
 
 
40955
Write a statement to assign to weight_in_pounds the value of weight_in_kilos times 2.2. (The variables  have already been declared and weight_in_kilos has already been initialized.)
 
weight_in_pounds = weight_in_kilos * 2.2
 
40348
 
 Given two int variables , i and j, which have been declared and initialized, and two other int variables , itemp and jtemp, which have been declared, write some code that swaps the values i i and j by copying their values to itemp and jtemp, respectively, and then copying itemp and jtemp to j and i, respectively. 
 
itemp = i
jtemp =j
j = itemp
i = jtemp
 
 
 
 
 
 
precedence:
 
 
40333
Write an expression that computes the average of the values 12 and 40

(12 + 40) / 2
 
 
40334
 
Write an expression that computes the average of the variables  exam1 and exam2 (both declared and assigned values). 

(exam1 + exam2) / 2
 
41100 
 
Assume that an int variable  x has already been declared,.
Write an expression whose value is the last (rightmost) digit of x.
 
 
x mod 10
 
41001
 
Assume that price is an integer variable  whose value is the price (in US currency) in cents of an item. Assuming the item is paid for with a minimum amount of change and just single dollars, write an expression for the number of single dollars that would have to be paid. 


price \ 100

41013
 
The dimensions (width and length) of room1 have been read into two variables : width1 and length1. The dimensions of room2 have been read into two other variables : width2 and length2. Write a single expression whose value is the total area of the two rooms. 

(width1 * length1) + (width2 * length2)
41014
 
A wall has been built with two pieces of sheetrock, a smaller one and a larger one. The length of the smaller one is stored in the variable  small. Similarly, the length of the larger one is stored in the variable  large. Write a single expression whose value is the length of this wall.

small + large

41015 
 
Each of the walls of a room with square dimensions has been built with two pieces of sheetrock, a smaller one and a larger one. The length of all the smaller ones is the same and is stored in the variable  small. Similarly, the length of all the larger ones is the same and is stored in the variable  large. Write a single expression whose value is the total area of this room. DO NOT use the pow function. 

(small + large) ^2

41016
 
Three classes of school children are selling tickets to the school play. The number of tickets sold by these classes, and the number of children in each of the classes have been read into these variables :tickets1, tickets2, tickets3 and class1, class2, class3. Write an expression for the average number of tickets sold per school child. 

(tickets1 + tickets2 + tickets3) / (class1 + class2 + class3)

41017
 
In mathematics, the Nth harmonic number is defined to be 1 + 1/2 + 1/3 + 1/4 + ... + 1/N. So, the first harmonic number is 1, the second is 1.5, the third is 1.83333... and so on. Write an expression whose value is the 8th harmonic number. 

1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7 + 1/8

41018
 
In mathematics, the Nth harmonic number is defined to be 1 + 1/2 + 1/3 + 1/4 + ... + 1/N. So, the first harmonic number is 1, the second is 1.5, the third is 1.83333... and so on. Assume that n is an integer variable  whose value is some positive integer N. Assume also that hn is a double variable  whose value is the Nth harmonic number. Write an expression whose value is the (N+1)th harmonic number. 

hn + 1 / (N+1)


41019
 
Assume that children is an integer variable  containing the number of children in a community and that families is an integer variable  containing the number of families in the same community. Write an expression whose value is the average number of children per family.
41020
 
Assume that children is an integer variable  containing the number of children in a community and that families is an integer variable  containing the number of families in the same community. Write an expression whose value is the average number of children per family.
41021
 
Assume that price is an integer variable  whose value is the price (in US currency) in cents of an item. Assuming the item is paid for with a minimum amount of change and just single dollars, write an expression for the number of single dollars that would have to be paid.
41022
 
 
Assume that price is an integer variable  whose value is the price (in US currency) in cents of an item. Assuming the item is paid for with a minimum amount of change and just single dollars, write an expression for the amount of change (in cents) that would have to be paid.
 
 
 
combined assignment:
40189
 
Write a statement that increments the value of the int variable  total by the value of the int variable  amount. That is, add the value of amount to total and assign the result to total.
 
40341
 
Given an integer variable  bridgePlayers, write an statement that increases the value of that variable  by 4.
 
 
40342
 
Given an integer variable  profits, write a statement that increases the value of that variable  by a factor of 10. 

40960 
 
Write a statement using a compound assignment operator to add 5 to val (an integer variable  that has already been declared and initialized).
40961
 
  Write a statement using a compound assignment operator to subtract 10 from minutes_left (an integer variable  that has already been declared and initialized).
40962
 
  Write a statement using a compound assignment operator to cut the value of pay in half (pay is an integer variable  that has already been declared and initialized).
40963
  Write a statement using a compound assignment operator to multiply num_rabbits by 4, changing the value of num_rabbits (num_rabbits has already been declared and initialized).
 
 
 
mixing different data types:
 
formatting numbers and dates:
 
 
40010 
 
Assume that m is an integer variable  that has been given a value. Write a statement that assign to the string variable  s the formatted string corresponding to the value of m with two digits to the right of the decmial point and thousands separators.
 
40015
Use the ToString method with a format string to convert the double variable , pi to the string variable , s, in fixed point format and 4 digits of precision.
 
40016
Use the ToString method with a format string to convert the double variable , pi to the string variable , s, in scientific point format and 3 digits of precision.
 
40014
 
Assume that pricePerDozen is an variable  that has been given a value. Write a sequence of statements that assigns to the string perEgg a string formatted as Currency and containing the price per egg.
40017
 
Assume that numQuestions and numCorrect are variables  that has been given values. Write a sequence of statements that assigns to the string percentIncorrect a string formatted as a percentage indicating the percentage of INCORRECT questions correct to two decimal places.
40013
 Assume that m is an integer variable  that has been given a value. Write a statement that assign to the string variable  s the formatted string corresponding to the value of m with two digits to the right of the decmial point and thousands separators.
 
 
 
3.6 Class-Level Variables
 
3.7 Exception Handling
 
40011
 
Assume that s is a string variable  that is supposed to contain a value to be converted to integer. Write a fragment of code that converts the value to integer variable  and displays that value multipled by 2. If the value cannot be converted, display the message 'Invalid number' instead.
 
 
Try
MessageBox.Show(CInt(s) * 2)
Catch
MessageBox.Show("Invalid number")
End Try