Tumgik
capybar · 6 months
Text
Consider the recurrence relation defined in Example 3.3. Suppose that, as in the example, you borrow $900, but you pay her back $100 each week. Each week, Ursula charges you 10% interest on the amount you still owe, after your $100 payment is taken into account.
n=900 for i in range(0,4): n=1.1*(n-100) print(n)
I'm just so happy I came up w the solution on my own bc I didn't want to do math by hand
1 note · View note
capybar · 4 years
Text
Write code in the addNewCat method to increase the number of cats by 1 each time it is called.
The variable catCount corresponds to the number of cats. The Cat class must have only one catCount variable. The variable catCount must be a static int, have a private access modifier, and be initialized to zero. The Cat class must have two methods: addNewCat and main. The Cat class's addNewCat method should increase the number of cats by 1.
Requirements:
public class Cat { private static int catCount = 0; public static void addNewCat() { int cat= catCount++; System.out.println(cat); //write your code here } public static void main(String[] args) { addNewCat(); } }
Here's a second task I thought I understood this but maybe not. I'm not really sure about object creation and object referencing. I don't know why I feel lke I understood it a few months age.
Finish writing the code of the setName method so that it sets the value of private String fullName to the value of the local String variable fullName. private String fullName; public void setName(String firstName, String lastName) { String fullName = firstName + " " + lastName; this.fullName= fullName; //write your code here } public static void main(String[] args) { } }
1 note · View note
capybar · 4 years
Text
Back to Java after abandoning it for a few weeks. I like that Codegym is repetitive. Anyway this exercise is the same as the last.
Help the cat get a name using the setName method.
Requirements:
•The Cat class must contain only one variable called name. •The variable name must be a String and have a private access modifier. •The Cat class must have only two methods: setName and main. •The Cat class's setName method must set the value of the private String variable name equal to the passed String argument name.
My solution is below
public class Cat { private String name = "nameless cat"; public void setName(String name) { this.name = name; } public static void main(String[] args) { Cat cat = new Cat(); cat.setName("Simba"); System.out.println(cat.name); } }
1 note · View note
capybar · 4 years
Text
I finished an 11ty course that was dependent on http-proxy and it’s made me double down on my already negative feelings about using things requiring npm libraries.
0 notes
capybar · 4 years
Photo
Tumblr media
Instead of blogging, I spent forever looking for a good markdown text editor and then an extra few minutes fidgeting around with this theme. I'm not good at using Github and so am doing kind of tiny projects to get comfortable with basic things like push and stuff. This theme is built on top of John Otander's Pyxill theme.
See it here
0 notes
capybar · 4 years
Text
ET5: This in Java
public static class Person { public int age = 20; public void adjustAge(int age) { age =age + 20; this.age=age; System.out.println("The age in adjustAge() is " + age); } }
0 notes
capybar · 4 years
Quote
I don’t want to get into middle eastern politics but…when someone orders a hundred centrifuges, you have to be a little suspicious
RJM (via slurppi)
5 notes · View notes
capybar · 4 years
Text
Task not Written Well
Tumblr media
I’ve never wrote a negative post about Codegym but there’s a place and time for everything (this site is still the best there is imho). The instructions need clarification. The order that the input is accepted in is important. It must be number and then name (although it’s not printed like that). And while you are accepting an input by the user YOU aren’t actually inputting anything. Basically you don’t have to print statements like “put in a number”.
0 notes
capybar · 4 years
Text
Print a this Statement
Here is the prompt:
Display the following text (two lines): This is a Windows path: "C:\Program Files\Java\jdk1.8.0_172\bin" This is a Java string: \"C:\\Program Files\\Java\\jdk1.8.0_172\\bin\"
Hint: \” – Insert a double quote character in the text at this point. 
\ – Insert a backslash character in the text at this point. 
\n-new line
And below is my solution. I tried many ways and I suggest you try the same before looking at my solutions. I thought about using a for loop but instead chose not to because I think I rely on it too much. Next, I tried using special characters within the statement but that proved too difficult to keep track of. So finally I decided on going back to basics and sticking with the tried and true of using variables. 
public class Solution { public static void main(String[] args) { String a="\""; String b="\\"; String c="\\\\"; String d="This is a Windows path:"; String e="This is a Java string:"; System.out.println(d+" "+a+"C:"+b+"Program Files"+b+"Java"+b+"jdk1.8.0_172"+b+"bin"+a +"\n"+e+" "+b+a+"C:"+c+"Program Files"+c+"Java"+c+"jdk1.8.0_172"+c+"bin"+b+a); //write your code here } }
0 notes
capybar · 4 years
Text
Multiplacation Table
Ill edit later
package com.codegym.task.task03.task0314; /* Multiplication table */ public class Solution { public static void main(String[] args) { for (int i=1; i<=10; i++){ for (int j=1; j<=10; j++){ System.out.print(i*j+" "); } System.out.println(); } //write your code here } }
Explain
0 notes
capybar · 4 years
Text
Pretty Easy Conversion
public class Solution { public static int convertToSeconds(int hour){ int seconds=hour*60*60; return seconds; } //write your code here public static void main(String[] args) { System.out.println(convertToSeconds(2)); System.out.println(convertToSeconds(4)); //write your code here } }
This is a simple program that converts hours to seconds. The VERY basic mistake I made was trying to use the print function in an int function and then call it in the main class.
1 note · View note
capybar · 4 years
Text
Minimum of 4 numbers
I legit feel so smart bc I like sat down with a pen and paper and just...worked through the problem for the base case (compare 3 numbers and find the smallest).
This is really the same thing. You're referencing an object (or a function) and using it to find a minimum and then basically comparing the two objects to each other. Does this make sense? Will I know what I'm talking about a month from now???
So first: how do you find out if a is a bigger number than b? After that, how do you find out if it is bigger than C? How about D? Reduce the problem of comparing 4 numbers to comparing two numbers.
public static int min(int a, int b, int c, int d) { int m=min(a,b); int n=min(b,c); int o=min(c,d); if (m<=n && m<=o) return m; else if (n<=m && n<=o) return n; else return o; } public static int min(int a, int b) { if (b<=a) return b; else return a;//write your code here }
1 note · View note
capybar · 4 years
Text
Understanding Objects Part 1
I’m going to relate this to Starbucks because-hey, I work there. The best way to think of classes are as vague unspecific objects and objects as a specific instance of that object. For example, Starbucks has baristas and shift supervisors. Here are the descriptions of the two classes (Barista and Shift Supervisor) Baristas: * Clean Things * Make Customers Happy * Make Drinks Shift Supervisors: * Delegate Tasks * Count things (like food) There are multiple baristas-these baristas are objects: * John * Age: 22 * Years worked .5* Jimbo And there are multiple shifts: * Steve * Age: 44 * Years Worked: 7* Felixia public class Starbuckspartners { //this is the main class public static void main(String[] args) { //creating a new object: a barista Barista barista1 = new Barista(); //naming the barista barista1.name = "John"; Barista barista2 = new Barista(); barista2.name = "Steve"; } public static class Barista { //this is the barista class public String name; } }
2 notes · View notes
capybar · 5 years
Text
Spell it out! Java Star Pyramid
Tumblr media
A classic assignment that I never understood was making an asterisks pyramid that looks like this:
How do they do it? What's going on?
I'm going to explain it the way I would have liked it explained to me: very slowly and everything spelled out.
This assignment tests your understanding of for loops.
A loop is something that gets repeated over and over again until you tell it to stop. Example: Keep catching Pokemon until you run out of Poke balls.** Terminate** means to end. So when you are out of Poke balls, you can no longer catch Pokemon. Your program will terminate.
The for _in for loop specifies _a condition that has to be met in order to start and end a program. Continuing with Pokemon Go:
 For the number of Pokemon balls that we have (starting with 1), we're going to keep catching Pokemon until we use all the Pokemon balls that we have (let's say that's idk 12).
Here Pokeball=1 starts the loop
Pokeball<=12 let's us know when to end the loop
Pokeball++ tells us how we're evaluating the steps to complete the loop. We're incrementing here because we're counting from 1 Pokemon balls to less than or equal to 12.
Back to our star program:
Tumblr media
We need to first define the number of rows: 5. There are two parts to the program: an inner loop and an outer loop:
The inner loop says to print out asterisks like this: 1 asterisk followed by two asterisks followed by 3 asterisks all the way to 5 asterisks all in a straight line. You'll end up with a line of 15 asterisks.
The outer loop tells us to create a new line after every set of asterisks. So 1 asterisk-new line. 2 asterisks-new line, three asterisk-new line...all the way to five. You end up with five lines with every line having one more asterisk more than the previous! And voila!
1 note · View note
capybar · 5 years
Text
Codeland: My First Conference
Let me tell you: it was an adventure. We need to start at the very beginning.
Arriving in NYC
I (last minute) bought tickets via Grayhound and booked a hotel to the New World Hotel. The Grayhound bus driver didn't accept my e-ticket so I had to dig around my phone for a printable receipt. I landed in Port Authority around 9.30pm on Sunday. But I didn't know how to use the subway and was too anxious to ask for help so I walked from there all the way to the hotel. Of course, my phone ran out of battery so I had to drop by a Duane Reid to purchase an emergency batter pack. The hotel wasn't obscenely far but I am poor with direction, thus I arrived at 11.30pm. The hotel reeked of cigarettes and there was an unkempt mattress propped against a wall along with hand towels strewn in random places. I checked in, got my keys and went to my (very small) room. The bed sheet was disgusting and there was a loud TV blasting the benefits of Chinese healing cream that could make you look significantly younger. I tried to go to sleep but couldn't because I felt super itchy. By 4.45am I gave up, checked out of the hotel and wandered around Bower St. looking for a place to shower. At 6am I stumbled into a YMCA. They were generous and because it was my first time there, let me shower for free. I almost passed out in the shower from sleep deprivation.
At the Conference
Finally after an hours' respite (thanks YMCA!), it was off to the conference! The line to the NYC Skirball was decently sized. Getting inside was easy. The conference was super well organized. I got a small pink tote bag that was filled with goodies (hey Flatiron, thanks for the battery pack). The breakfast was much needed. I was beyond thankful for Flatiron's lattes.
The beginning. talks had dancing-which made me really nervous (I didn't want people to see how visibly sleepy drunk I was).
Luna Malbroux's talk was hilarious. It reminded me of Starbucks' #racetogether movement (one question the Bux posed was: how many people did you eat with who wasn't the same race as you? And how often? Well my brother is a different race and I, a Chinese person, am surrounded by white people so this is often. However, this absolutely doesn't make me more #woke). I loved the fake app and everything about the talk.
Pedro Cruz's speech was inspiring. A lot of the programming hype is around the fat paychech or making beaufitulf design or having a snazzy "programmer" lifestyle, but I love how he talked about an existing problem and how he tried to solve it using existing technology. He's truly made a difference in Puerto Rico, moreso I can easily see his solution being used globally (it probly is). His DronAid tackled many problems, from recieving "Help" messages from people in need, to seeing what they actually needed, to making sure non profits weren't getting redundent information to creating a form of communicatlion between various groups.
I chose Raymond Camden's Real Person's Guide to Vue.js. I'm new to learning JavaScript (I only know HTML and CSS) but I've always wanted to know: why do people always talk about Vue, React and Angular? What's the big deal? Although this talk was aimed towards more advanced web developers (aka not COMPLETE noobies), I gained so much from this workshop (plus cats!! A lot of them!!). I learned how useful Vue could be for acquiring data and also allowing interactions between the user and the site. I've been able to go over his github and Codepen at a (much) slower pace to fully peice together the workshop.
The closing talks were very fun and entertaining. I loved Ali Spittal's talk about blogging (I'm going to try to put real effort). It is necessary for me to explain what I'm learning to someone so I can sort of figure out what I'm learning. It is also a good way to keep myself organized. Building a Gendered Dictionary and An Immigrant's Journey into Tech hit home with me as I think we should consider what we are doing and how they impact society.
Coding is a tool. It's what we do with it that matters.
I didn't go to the afterparty but next year, now that I know better how to plan my trip, I will!
2 notes · View notes
capybar · 5 years
Text
Being Honest with Myself: Failing at Teaching Myself
People like to say “starting is half the battle” and maybe it is...but for me, starting is easy. It’s continuing on that is difficult. 
The reason why people are terrible with diets is that they’re not consistent. They make a plan for accomplishing a goal but not what to do once the goal is reached.  They lose 100 pounds and then stop exercising and dieting correctly. Two months later, they wonder “hmm...how did all this weight come back?” *. This is a dilemma in any goal that requires persistence. For me, it’s learning to program. I’ve started numerous tutorials and finished a handful of them. The problem is that I’m not consistent with practice. I don’t program an hour a day and I should. This should be on my calendar.  This goal is easy on weeks where I work 25 hours. But 40? Nope, not happening.
The “Hustle and Grind” culture tells me it’s on me. There’s a quote that goes something like this:
If you’re truly passionate, you’ll find a way
Am I not truly passionate then? I know I don’t actually want to program (after all, programming is just a tool used to accomplish something else). I want to create useful products with logic and creativity. Is programming not meant for me? I don’t know.
I’ve gotten decent at things I don’t care too much for. Pressure and guidance from my favorite professor have helped me be decent at math. These two things from my manager have helped be a decent supervisor in retail. But programming? No one is pressuring me to be good at it. Only me...and I am not a good boss.I’m good at learning with other people. But I can’t seem to do this on my own at home in front of my laptop...trying but not succeeding.
CodeNewbies on twitter is great and so is Dev.to...and yet....
I was able to teach myself how to make a Tumblr theme. I’ve learned HTML, CSS and a bit of JavaScript. So why is mastering Python on my own so difficult? Why is being beyond a beginner in JavaScript such a chore? 
*I realize some people actually have health problems that make losing/gaining weight difficult  
2 notes · View notes
capybar · 5 years
Text
Day 3: Installing Github
A few days ago I installed Github (which is a platform that let’s you version control what you’re doing-that is you can track the changes you make to any file you’re creating).
I have a lot of my Tumblr themes on there right now and a Jekyll blog that I don’t really post on. I feel like I’m still not using it right.
I need to get better at balancing my life. I’m not good at sticking to a schedule. 
4 notes · View notes