Sunday, September 9, 2012

The first week of AP Computer Science was one of the most nerve-wracking and exciting classes of the week. Somehow, I pulled through. Because I don't have a background in CS, I was thoroughly confused with Java syntax. I was told that Java syntax is more confusing than most of the other CS languages out there, and I can see why. On Friday, we programmed 4 different programs in order to learn data types, variables, and input. Here are the steps to create such a program:

1) import java.util.Scanner; // This imports Scanner

2) public class ______ (topic... Ex: Age) // This is the class

3) {

4) public static void main(String args[]); // This is within the class

5) {

6) int _____; // This will be your first variable (Ex: years), put all variables at beginning

7) Scanner scan = new Scanner(System.in); // This creates a new Scanner object

8) System.out.println("_______?"); // Type something directing user to input a value

9) years = scan.nextInt(); // Scanner brings in an int value

10) years = years*2; // Type your function or calculation here

11) System.out.print("Your age doubled is "); // You will see this before the number that gets calculated

12) System.out.println(years); // This shows the calculated number

13) }

14) } 


Depending on what program you want to create, the calculations and variables will vary. This was complicated for me because we basically flipped through the slides very fast and I couldn't exactly comprehend or absorb any of the information. Until I actually did it, I didn't know where to start, and maybe if there was more clarification on what each line actually DOES, I would catch on quicker. Java syntax is so confusing to me, so it will probably be helpful for the present and future if the function of each line was explained in more detail. Otherwise, programming is really fun once you actually get it to work. CS turned out to be more fun than I anticipated.


No comments:

Post a Comment