1337 times 32

Write any expression that evaluates to the same thing as the product of 1337 and 32

Sally's even more apples

Sally had six thousand, four hundred and thirty two apples and she give four thousand and to Billy. Write an expression for the number of apples Sally has now.

Area of circle with radius 2

Write any expression that evaluates to the area of a circle with radius two. (Recall that the formula for the area of a circle is π times the square of the circle's radius.) You can use Math.PI to get a good approximation of π.

Seconds in a day

Write any expression that evaluates to the number of seconds in a day.

Sum

The sum of two numbers is what you get when you add them together. Write an expression for the sum of the two numbers a and b.

Difference

The difference between two numbers is what you get when you subtract the second from the first. Write an expression for the difference between the two numbers a and b.

Product

The product of two numbers is what you get when you multiply them. Write an expression for the product of the two numbers a and b.

Ratio

The ratio between two numbers is what you get when you divide the first by the second. Write an expression for the ratio of the two numbers a and b.

Remainder

The remainder of of dividing one number by another is the integer part left over after doing a division. Write an expression for the reminder after dividing a by b.

Average

The average of two numbers is their sum divided by two. Write an expression for the average of the two numbers a and b.

Distance

The distance between two numbers (e.g. on the number line) is the absolute value of their difference. The Math.abs function returns the absolute value of its argument. Write an expression that computes the distance between two numbers a and b.

Manhattan distance

The “Manhattan distance” between two points in 2d space is the sum of the distance between the points along the x axis (crosstown) and the distance between the points along the y axis (uptown/downtown). Write an expression that computes the Manhattan distance between two points the first whose x,y coordinates are given by the numbers x1 and y1 and the second by the numbers x2 and y2.

Doing well?

Someone is doing well if they are getting enough sleep and also keeping up with their schoolwork. Write an expression that expresses whether someone is doing well given two boolean values enoughSleep and keepingUp.

Energetic?

Someone is feeling energetic if they are getting enough sleep and aren't exhausted from having just worked out. Write an expression that expresses whether someone is energetic given two boolean values enoughSleep and justWorkedOut.

Dragging?

Someone is really dragging if they haven’t gotten enough sleep and have lots of work to do. Write an expression that says whether someone is dragging, given two boolean values enoughSleep and lotsOfWork.

Super beat?

Someone is super beat if they haven’t gotten enough sleep and haven’t had enough to eat. Write an expression that says whether someone is super beat given two boolean values enoughSleep and eatenEnough.

Can go to prom?

Roughly speaking, someone can go to Senior Prom if they are a senior or if they are invited by a senior. Write an expression that says whether someone can go to prom given the two boolean values isSenior and invitedBySenior. (In a later problem set we’ll deal with the more complex reality of the prom exclusion list.)

Having fun?

If someone is working on something for their own reasons they don’t need to keep going if it’s not fun any more. So they will stop when they’re done or when it’s not fun anymore. Write an expression that says whether they should stop given the two boolean values done and fun.

Not feeling it?

Someeone is working on something and aren’t that into it so they’ll quit if it’s not fun. And even if it is fun but they’re feeling tired they’ll also call it quits. Write an expression that says whether they’ll stop given the two boolean values fun and tired.

Time to sleep?

Someone is unable to go to sleep unless it’s totally dark. Also they obviously can’t sleep when they’re not sleepy. Write an expression that says whether they’re awake given the boolean values sleepy and dark.

Will we skip our trip to the store?

We want to go shopping but we obviously won’t if the store isn’t open. But we’ll also wait for another day if the lines are too long. Write an expression that says whether we’ll skip our planned shopping trip given the two boolean values storeOpen and linesTooLong.

Wait for a sale?

Now we want to go shopping, but only if the store is having a sale. As before we obviously won’t go if the store isn’t open but we’ll also skip the trip if the store isn’t having a sale. Write an expression using the two boolean values storeOpen and isASale that says whether we’ll hold off on our trip to the store.

Coming to bookclub?

The book club meets today. We’d expect someone to be at book club if they’re a member as long as they’re not out sick from school. Write an expression that says whether we expect someone to be at book club given the two boolean values member and outSick.

Ready for some football?

The football team is very picky and will only allow people on the team who are both fast and strong. Write an expression in terms of the two boolean values fast and strong that says whether someone has a chance to be on the team.

Lighting a fire?

You’re on a camping trip and you’re trying to light a fire. Unfortunately you’re having some trouble and are running out of matches. You’ll stop trying when the fire is lit or when you run out of matches, whichever comes first. Write an expressian that says whether you can stop trying using the two boolean values fireLit and haveMatches.

Can pay attention?

It can be hard to pay attention if you’re distracted by being hungry. And obviously it also hard to pay attention to things that you’re not interested in. Write an expression that says whether you can pay attention to something given the two boolean values hungry and interested.

In the room where it happens?

A student should be in our classroom during our class only if they’re in the class or are a student proctor. Write an expression that says whether a student should be in the classroom during our class given the two boolean values inTheClass and isProctor.

Can go into creepy crawly cave?

There’s a dark cave full of spiders. You should only go in if you’re not afraid of th>e dark nor of spiders. Write a boolean expression using the two values afraidOfTheDark and afraidOfSpiders that says whether you could go into the cave.

Concatenate (smoosh) strings

Write an expression the evaluates to the concatenation of the values of the string variables s1 and s2.

First character

Write an expression the evaluates to the first character of the value of the string variable s.

Length

Write an expressions that evaluates to the length of the string value of the variable s.

Last character

Write an expression the evaluates to the last character of the value of the string variable s.

All but first

Write an expression the evaluates to a string containing all but the first character of the string in variable s.

First three

Write an expression the evaluates to a string containing the first three character of the string in variable s.

All but first and last

Write an expression the evaluates to a string containing all but the first and last character of the string in variable s.

Last three

Write an expression the evaluates to a string containing the last three character of the string in variable s.

UPPER CASE

Write an expression the evaluates to the value of the string variable s converted to all upper case.

lower case

Write an expression the evaluates to the value of the string variable s converted to all lower case.

Capitalize

Write an expression the evaluates to the the value of the string variable s with the first letter capitalized and the remaining letters in lower case.

Capitalize first three

Write an expression the evaluates to the the value of the string variable s with the first three letters capitalized and the remaining letters in lower case.