Answer:
Hi!
The answer in Javascript is:
function monthsWithMoreOfThree() {
var Rainfall_mi = '3,4,1,5,2,6,7,9'; <em>//Defined and declared</em>
var num_rainy_months = 0;
var values = Rainfall_mi.split(","); <em>//use split method for Strings. Array is returned</em>
for (var i = 0; i < values.length; i++) { <em>//for each value, compares with 3</em>
if(values[i] > 3) { <em>//In Javascript, you can compare an String value with an int. Can use parseInt(aString) to explicit parse but is not necessary</em>
num_rainy_months++; <em>//If value is greater than 3, adds 1 to num_rainy_months</em>
}
}
}
I've got task manager open right now; it shows you
- Applications
- Processes
- Services
- Performance
- Networking
- Users
(In that order)
Answer:
if(revenue.cents - expenses.cents < 0){
profit.dollars = revenue.dollars - expenses.dollars - 1;
profit.cents = 1 - revenue.cents - expenses.cents;
}
else{
profit.dollars = revenue.dollars - expenses.dollars;
profit.cents = revenue.cents - expenses.cents;
}
Explanation:
We know that profit is given as: revenue - expenses from the question.
From the given expression above;
if(revenue.cents - expenses.cents < 0)
then profit.dollar will be revenue.dollars - expenses.dollars - 1; the 1 is to be carry over to the cent part. And the profit.cent will be 1 - revenue.cents - expenses.cents;
else the profit.dollars and the profit.cent is computed directly without needing to carry over:
profit.dollars = revenue.dollars - expenses.dollars;
profit.cents = revenue.cents - expenses.cents;