This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Create a variable in main() and set its value to 50. | |
| make a function outside main() that will return the nth value of the Fib Seq | |
| - this function will take in a named parameter that is an int representing the seq num we wish to find | |
| identify the first two known values of the sequence (0 & 1) | |
| since you're going through all numbers up to that point a for loop is required | |
| start at 3, as the next number to calculate is the third number in the sequence | |
| identify the procedure of the formula to the function for that next number | |
| -knowing the formula is: the next value is the sum of its previous 2 | |
| proceed to say how each number changes from there |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Take the Beer on the Wall song and transition that to code. | |
| Make the number of bottles and the beverage type able to change in main() | |
| void function as you're printing in function | |
| you're going through each step in the loooong song | |
| so a for loop is needed | |
| number of bottles is all you have so the integer to begin with must be the number of bottles | |
| (which in the song goes up to 99) - so that's a parameter | |
| Beverage type in the song is beer - so that's also a parameter | |
| To change both the number of bottles and the beverage type - make them named {} - to easily tell what you're passing in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Compare a list of winning numbers to your own two tickets! How many matching numbers do you have? | |
| --- | |
| Make a list of int above main() | |
| within main() add the two tickets as lists and name them for reference | |
| You're only comparing to one list so keep that name the same | |
| That name will be the name of your void function (to print out at the end of it) | |
| Set the parameter as a list of int | |
| you need to compare ticket 1 to winning numbers and ticket 2 to winning numbers | |
| since you're looking at two lists at the SAME TIME a nested for-in loop is needed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Pass in a String into a function in main() | |
| make a function that returns nothing (printing in function) | |
| set the function to take in a string as a named parameter {} | |
| need to separate the words within and then reverse them finally join them | |
| make a list of the separated words | |
| use . methods to see if any options look like what I need for all 3 actions | |
| attach their action name one at a time and in order | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| All within main() to keep the requirements together | |
| must go through each number out of a bunch that's not in a list, so a for loop is best | |
| the count starts at one so it initializes on that number | |
| each number between must be analyzed including the last (100) | |
| each time a number is analyzed in order | |
| must use Modulo: returns the remainder of two integers when they are divided by each other | |
| order is necessary for FizzBuzz | |
| -it needs to print before any of the other words otherwise the wrong word would be printed | |
| -once an if statement finds something true, it stops its cycle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Create a variable that stores an integer that the user provides | |
| completing a repetitive task means using a for loop | |
| simple - so it can stay within main() - but can make a function if preferred | |
| Prime Number is a whole number greater than 1 that cannot be divided by any whole number | |
| other than itself and 1 | |
| Since 1 is valid, the initial check must start at 2 and go up from there | |
| - can add by one as you can check all numbers in between | |
| if statement with modulo will help determine if it is divisible by user given number | |
| - if it is then it's not prime so set that if statement to say false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Make a list containing 4, 5, & 6 (integers) and name it | |
| Both requests ask to look for an object within a list, so for loops are needed for both | |
| void needs to be return type for sum as you're printing in the function and not returning anything | |
| return type of product function should be int (before the name of the function) | |
| as you need to return to main to print, | |
| also need to wrap in {} to make the parameter named | |
| print and returns go outside of the loop | |
| sum must start with 0 in order to account for the first number | |
| same logic for product, but must be 1 or all the values will be 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Create list of Names | |
| make a variable that is equal to what the user inputs in order to find that name | |
| Create a function that returns a list of names | |
| Parameters must reference the list and what the user inputs | |
| To check the names within the list you'll need a for in loop | |
| That loop will need an empy list to store any matches | |
| account for caplitalization | |
| - if user messes up be prepared by allowing the loop to automatically make sense of all letters | |
| -uppercase or lowercase |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| *Create a list of integers and generate the two largest out of that list. | |
| Integer: a whole number (not fractional) that can be positive, negative, or zero | |
| Requirements: | |
| Print out what the two largest are inside of the function to start with. | |
| The List<int> that you pass in can be of any length, but not null | |
| (List<int>? type would be nullable) | |
| Do not use sort() | |
| The largest and second largest cannot be the same number | |
| If list were to change, consider nulls and print a statement for each scenario in main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| // Object = new version of that class(); | |
| Car normalCar = Car(); | |
| print(normalCar.numberOfSeats); | |
| normalCar.drive(); | |
| ElectricCar coCo = ElectricCar(); | |
| coCo.drive(); | |
| coCo.rechargeBattery(); | |
| LevitatingCar aLevitatingCar = LevitatingCar(); | |
| aLevitatingCar.drive(); |
OlderNewer