This week in computer science it was the first time we worked in JCreator in over three weeks and I had forgotten some things about the program. However, those specific skills weren't necessary to complete the labs this week. The labs focused on calling on a method that could solve mathematical equations, including finding the sum or average of two or three numbers. The labs required you to create a second method where all the calculations would take place. This worked by assigning a value to a variable in the main method and then assigning that variable with a value to a variable in the second method. For example in the main method you would assign the value 5 to the variable 'num1', and then assign 'num1' to the variable 'one' in the second method. Now that you have variables you're able to use in the second method you had to create another variable that was equivalent to the sum or average (depending on the lab) of the values. After creating and assigning values to the variables you had to print out the equation. This is where things got frustrating. To print out and equation you had to type out the equation and plus signs in between each part to get everything to print the way you wanted it to. For example to print out one + one = sum, you had to type out System.out.println(" one " + " + " + " one " + " = " + " 10 "). If you typed out System.out.println(" one + one = sum") you would get one + one = sum in words, not their actual values. The overall procedure makes sense, but the typing requirements make things more complicated than anything else in the method.
-jag13
No comments:
Post a Comment