package assignment_9_muratore; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.InputMismatchException; import java.util.Scanner; public class Problems { // CHP 14 EX 3 public static void division() { Scanner stdIn = new Scanner(System.in); int n, d, q; System.out.println("Enter numerator: "); n = stdIn.nextInt(); System.out.println("Enter divisor: "); d = stdIn.nextInt(); try { q = n / d; System.out.println(q); } catch (ArithmeticException e) { System.out.println("Error, but keep going anyway."); } stdIn.close(); } // CHP 14 EX 4 public static void division2() { Scanner stdIn = new Scanner(System.in); double n = 0; int d = 0; boolean OK = false; while (OK == false) { try { System.out.print("Enter numerator: "); n = stdIn.nextDouble(); while (d == 0) { System.out.print("Enter divisor: "); d = stdIn.nextInt(); if (d == 0) System.out.println("Can not divide by 0."); } OK = true; } catch (InputMismatchException e) { System.out.println("Invalid input.. try again"); d = 0; n = 0; OK = false; // required to discard data stdIn.next(); } } System.out.println(n / d); stdIn.close(); } // CHP 15 EX 3 public static void testWriter() { String[] churchill = {"Before Alamein we never had a victory.", "After Alamein we never had a defeat."}; PrintWriter fileOut; try { // Append is false to start fileOut = new PrintWriter("elAlamein.txt"); for (String line : churchill) { fileOut.println(line); } fileOut.close(); } catch (FileNotFoundException e) { System.out.println(e.getMessage()); } } // CHP 15 EX 4 public static void appendWriter() { FileWriter fileOut; int year = 1942; try { fileOut = new FileWriter("elAlamein.txt", true); fileOut.write("Year " + Integer.toString(year)); fileOut.close(); } catch (IOException e) { System.out.println(e.getMessage()); } } public static void main(String[] args) { System.out.println("Running Division"); division(); System.out.println("Running Division2"); division2(); System.out.println("Running testWriter"); testWriter(); System.out.println("Running testAppend"); appendWriter(); } }
Jack Muratore
Computer Science Student
Sunday, May 4, 2014
Assignment 10
Tuesday, April 15, 2014
Homework 8
page 427, problem 9
1 2 3 4 5 6 7 8 | static public boolean allPositive(double[] arr) { for (int i = 0; i < arr.length; i++) { if (i < 0) return false; } return true; } |
page 427, problem 10
1 2 3 4 5 6 7 8 9 10 11 12 13 | public boolean equals(Students that) { if (this.studentIds.length != that.studentIds.length) return false; for (int i = 0; i < this.students.length;i++) { if (this.studentsIds[i] != that.students[i]) return false; } return true; } } |
page 468, problem 11
i = 5, factorial = 5
This happens cause the loop never runs the factorial *=
page 468, problem 12
1 2 | for (entry = ""; entry = stdIn.nextLine(); !entry.equals("q") ) System.out.println("Enter 'q' to quit: "); |
Tuesday, March 25, 2014
Java Class problems 4 and 12
Problem 4
public void swapHardDrive(Computer otherComputer) { String temp; temp = this.hardDrive; this.hardDrive = otherComputer.hardDrive; otherComputer.hardDrive = temp; }
Problem 12
Things in bold are output
- Contructore without parameter is called
- It calls the constructor with an int parameter of 20
- 10
- 20
- Sets private x value to 30
- 30
- Display without an argument is called
- Calls display with an argument set at 50
- Adds 10 to it so now its 60
- 60
- Prints the old x value since non objects are passed by value.
- 50
Tuesday, March 4, 2014
Java Assignment 6 and 7
Problem 6
while ( (foundIndex = songs.indexOf(searchText)) != -1) { foundIndex += searchText.length(); count++; }
Problem 7
songIndex = songs.indexOf(songNum); eolIndex = songs.indexOf("\n", songIndex); song = songs.substring(songIndex, eolIndex);
Tuesday, February 18, 2014
IT-415 Assignment 3
Problem 3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | public class HelloWorld{ public static void main(String []args){ int count = 0; int sum = 0; int product = 1; // Needed to be 1 do { count++; sum+= count; product *= count; if (count == 5) { // Brackets were needed for if statement System.out.println("Sum = " + sum); System.out.println("Product = " + product); } } while (count < 5); // Needed semicolon } } |
Problem 5
line# | i | debug | output |
3 | ? | ||
4 | ? | ||
5 | 0 | ||
10 | first | ||
5 | 1 | ||
13 | second | ||
5 | 2 | ||
17 | In default | ||
5 | 3 | ||
20 | i = 3 |
Sunday, November 24, 2013
IT-325 Reflection
This was a requirement for a class I took in web site design. The purpose of this post is to reflect on what I learned from the class.
Last summer I got an internship at the telecommunication company Commscope. I was originally suppose to do testing but because of a JavaScript contractor abandoning the project I ended up becoming the head JavaScript developer. When picking my schedule for Fall 2013 I choose this class in hopes that it would give me a better foundation for web developing.
I believe this class exceeding my expectations. It success is attributed to it being project driven. The best way to improve is to practice. I now have a better understanding of the tools required for website creation. My CSS was terrible coming into this class but afterwards I have enough knowledge that I was able to learn and use LESS to do all my CSS creations without the need of a framework such as bootstrap. In the class I also became familiar with PHP. Before, I always avoided PHP as it has a bad reputation of being an ugly language. I learned from using it that why it may have faults it can produce functional websites very quickly.
Currently, I am applying to full stack web engineer positions in NYC. I am unsure if my wife and I will be brave enough for the move but there is no better place on the east coast to find a cutting edge company. I am interested in more than just being a front end developer. I still enjoy the server side programming as well that I do at my current job.
This class was an excellent choice. I found it very useful in furthering my career.
Last summer I got an internship at the telecommunication company Commscope. I was originally suppose to do testing but because of a JavaScript contractor abandoning the project I ended up becoming the head JavaScript developer. When picking my schedule for Fall 2013 I choose this class in hopes that it would give me a better foundation for web developing.
I believe this class exceeding my expectations. It success is attributed to it being project driven. The best way to improve is to practice. I now have a better understanding of the tools required for website creation. My CSS was terrible coming into this class but afterwards I have enough knowledge that I was able to learn and use LESS to do all my CSS creations without the need of a framework such as bootstrap. In the class I also became familiar with PHP. Before, I always avoided PHP as it has a bad reputation of being an ugly language. I learned from using it that why it may have faults it can produce functional websites very quickly.
Currently, I am applying to full stack web engineer positions in NYC. I am unsure if my wife and I will be brave enough for the move but there is no better place on the east coast to find a cutting edge company. I am interested in more than just being a front end developer. I still enjoy the server side programming as well that I do at my current job.
This class was an excellent choice. I found it very useful in furthering my career.
Tuesday, May 15, 2012
Why I love Linux
It isn't about it being the best. Actually while it would be awesome if this is wrong, "Linux will never be the mainstream OS." This does not matter. I use Linux for the same reason that someone drives an impractical car. Because it is fun. When I toss this statement to people on why I use Linux they understand completely. Simply because there is something in everyone's life that they use simply because they enjoy it.
Using Linux gives the feel you are always getting your hands dirty. You are always learning something different. It exercises your brain. Sure you can say it sometimes gets in the way, but those obstacles are most of the fun of using it. I can't understand why people enjoy gardening. It's hard work that takes way too much time for the reward in the end, but people do it and enjoy it. The same regard can be used to my Linux use.
I suppose I can ramble more about this and it being fun is defiantly not the only reason I use Linux. I enjoy the freedom it gives me, knowing that anything on it can be changed by me even if I choose not to. I am also not against using a windows PC or a Mac. I love my ipad.
But if I could get away with it. I would use Linux for everything.
Using Linux gives the feel you are always getting your hands dirty. You are always learning something different. It exercises your brain. Sure you can say it sometimes gets in the way, but those obstacles are most of the fun of using it. I can't understand why people enjoy gardening. It's hard work that takes way too much time for the reward in the end, but people do it and enjoy it. The same regard can be used to my Linux use.
I suppose I can ramble more about this and it being fun is defiantly not the only reason I use Linux. I enjoy the freedom it gives me, knowing that anything on it can be changed by me even if I choose not to. I am also not against using a windows PC or a Mac. I love my ipad.
But if I could get away with it. I would use Linux for everything.
Subscribe to:
Posts (Atom)