From 555497dbcf31fd30402e25d31eb52d476df37617 Mon Sep 17 00:00:00 2001 From: Asad Ullah Date: Tue, 8 Dec 2020 19:48:56 -0500 Subject: [PATCH 1/3] added answers 1-5 --- problems/variables.js | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/problems/variables.js b/problems/variables.js index 831a97c..3c6a8b5 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -7,6 +7,15 @@ // * For example, if you were born in 1988, then in 2026 you'll be either 37 or 38, depending on what month it is in 2026. // * Log them to the screen like so: "I will be either `ageMin` or `ageMax` in `futureYear`", substituting the values. +// const birthYear = 1993 +// let futureYear = 3241 +// let ageMax = futureYear-birthYear +// let ageMin = ageMax - 1 + +// console.log("I will be either "+ ageMin + " or "+ ageMax + " in " + futureYear) + + + // ## Problem Two // Snack Supply Calculator: @@ -16,6 +25,17 @@ // * Calculate how many snacks you would eat total, from your current age until the maximum age. // * Log the result to the screen like this: "You will need `snackNumber` to last you until the age of `maxAge`". +// const maxAge = 30 +// let currentAge = 28 +// let snackNumber = 4 +// console.log ((maxAge - currentAge)* 365 * snackNumber) + +// snackNumber = 2920 +// console.log ("you will need "+ snackNumber +" to last you until "+ maxAge) + + + + // ## Problem Three // Calculate properties of a circle, using the definitions: http://math2.org/math/geometry/circles.htm @@ -24,6 +44,24 @@ // * Calculate the area based on the radius, and log "The area is `areaOfCircle`". // * Hint: https://www.w3schools.com/jsref/jsref_pi.asp + +// let radius = 5 +// let Pi = (Math.PI) +// let circumferenceResult = (2 * Pi * radius) +// console.log ("The circumference " + "is " + circumferenceResult ) +// let areaOfCircle = (Pi * radius * radius) +// console.log ("The area is " + areaOfCircle) + + + + + + + + + + + // ## Problem Four // Temperature Converter: @@ -32,6 +70,16 @@ // * Now store a fahrenheit temperature into a variable. // * Convert it to celsius and output "`tempInFahrenheit`°F is `tempInCelsius`°C." +// let tempInCelsius = 100 +// let tempInFahrenheit = tempInCelsius * 1.8 + 32 +// console.log (tempInCelsius + "°C is " + tempInFahrenheit + "°F") +// tempInFahrenheit = 50 +// tempInCelsius = ((tempInFahrenheit - 32) / 1.8 ) +// console.log ( tempInFahrenheit + "°F is " + tempInCelsius + "°C.") + + + + // ## Problem Five @@ -44,6 +92,15 @@ // * Find the average grade of all students // * Print out if Dee's grade is higher than the class average +let alicesGrade = 90 +let bobsGrade = 80 +let camsGrade = 85 +let averageGrade = (alicesGrade + bobsGrade + camsGrade) / 3 +console.log ( "The average grade is " + averageGrade ) +let deesGrade = 95 + averageGrade = (alicesGrade + bobsGrade + camsGrade + deesGrade) / 4 +console.log ( " The average grade of all the students is " + averageGrade ) +console.log ( " Dees grade of " + deesGrade + " is higher than the class average of " + averageGrade ) // ## Problem Six // Find the last number: From 1719f5f927628d8b138522a45217fbc315d1e1bd Mon Sep 17 00:00:00 2001 From: Kobe Date: Tue, 8 Dec 2020 20:00:57 -0500 Subject: [PATCH 2/3] added some answers --- problems/variables.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/problems/variables.js b/problems/variables.js index 831a97c..ebbf606 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -44,6 +44,20 @@ // * Find the average grade of all students // * Print out if Dee's grade is higher than the class average +// let aliceGrade = 90 +// let bobGrade = 80 +// let camGrade = 85 +// let averageGrade = ((aliceGrade + bobGrade + camGrade) / 3) + +// console.log("The average grade on the test is " + averageGrade) + +// let deesGrade = 95 +// averageGrade = ((aliceGrade + bobGrade + camGrade + deesGrade) / 4) + +// console.log("The average grade of all the students is " + averageGrade) + + + // ## Problem Six // Find the last number: @@ -82,6 +96,21 @@ // * alice + x = y * (bob + x) // * Solve for alice +const bobAge = 12 +let futureYear = 3 +let productAge = 2 +let aliceAge = (bobAge + futureYear) * productAge - futureYear + +console.log ("Alice age is " + aliceAge) + +futureYear = 1 +productAge = 3 +aliceAge = (bobAge + futureYear) * productAge - futureYear + +console.log ("Alice new age is " + aliceAge) + + + // ## Problem Eight // * Cat and Dog Percentages From d2899763ddb216ae7372cb2514b68d05f2a876b2 Mon Sep 17 00:00:00 2001 From: Asad Ullah Date: Tue, 8 Dec 2020 22:06:48 -0500 Subject: [PATCH 3/3] added answers --- problems/variables.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index 3c6a8b5..89adb75 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -92,15 +92,15 @@ // * Find the average grade of all students // * Print out if Dee's grade is higher than the class average -let alicesGrade = 90 -let bobsGrade = 80 -let camsGrade = 85 -let averageGrade = (alicesGrade + bobsGrade + camsGrade) / 3 -console.log ( "The average grade is " + averageGrade ) -let deesGrade = 95 - averageGrade = (alicesGrade + bobsGrade + camsGrade + deesGrade) / 4 -console.log ( " The average grade of all the students is " + averageGrade ) -console.log ( " Dees grade of " + deesGrade + " is higher than the class average of " + averageGrade ) +// let alicesGrade = 90 +// let bobsGrade = 80 +// let camsGrade = 85 +// let averageGrade = (alicesGrade + bobsGrade + camsGrade) / 3 +// console.log ( "The average grade is " + averageGrade ) +// let deesGrade = 95 +// averageGrade = (alicesGrade + bobsGrade + camsGrade + deesGrade) / 4 +// console.log ( " The average grade of all the students is " + averageGrade ) +// console.log ( " Dees grade of " + deesGrade + " is higher than the class average of " + averageGrade ) // ## Problem Six // Find the last number: @@ -110,11 +110,13 @@ console.log ( " Dees grade of " + deesGrade + " is higher than the class average // * a = 123 // * Output: // * 3 - // Hint: // Use the remainder % operator. + + + // ## Problem Seven // Alice's Age