# Search results

• Users: Arnoldjavs3
• In Engineering and Comp Sci Homework Help
• Order by date
1. ### Comp Sci Make an array with this series (java challenge)

That actually is the full problem description. Here's the link for more examples: http://codingbat.com/prob/p155405 I fixed the issue though. Like the quote above had stated, endpoint was greater than beginpoint so I had to fix that. The idea of 'subarray' was more or less just parts of the...
2. ### Comp Sci Make an array with this series (java challenge)

Turns out the line end=beginPoint+n-1 should be - n, not + n.
3. ### Comp Sci Make an array with this series (java challenge)

Homework Statement Given n>=0, create an array length n*n with the following pattern, shown here for n=3 : {0, 0, 1, 0, 2, 1, 3, 2, 1} (spaces added to show the 3 groups). Homework Equations The Attempt at a Solution public int[] squareUp(int n) { int length = n*n; int[]...
4. ### Having troubles with searching in specific fashion with bash

it is for a class, and unfortunately my freedom for how I solve the homework is limited. I have actually done what you stated before where it reads the file line by line, however I have a question. Say I have a condition: if [ substring is found in line i, col 10-15 ] then variable +=...
5. ### Having troubles with searching in specific fashion with bash

Homework Statement Say I have a textfile that is separated by columns, and I want to search columns 10-15. If there are any matches, then I want to cut out specific parts of all the matches and print it to the user. How do I do this? Homework Equations The Attempt at a Solution What I...

10. ### .profile missing in Unix (bash shell)

UNIX and bash shell. Someone had guided me there from unix.stackexchange. Although I'm feeling a lot more confident now, found a couple online tutorials that are great
11. ### .profile missing in Unix (bash shell)

I actually found it in /etc/skell/. It sucks because I have several books and they all point to different things; It's not a very uniform platform for me :(. I simply added in echo\$(user) and it worked. if you have a book similar to C by brian and ritchie I'm all ears - I have unix shell...
12. ### .profile missing in Unix (bash shell)

Homework Statement I'm playing around in UNIX and I wanted to modify my .profile file in my home directory, but It's not there. I know you type in ls -a to view the hidden files but it's simply not there. Do I just create one? I want it to just display my name every time i log in. Homework...
13. ### Algorithm for checking clumps inside an array not working

It was meant to prevent it from going out of bounds by only having it go through the second for loop as many times as it could(but clearly it does not achieve this, now I notice) Here is the new code that works!: public int countClumps(int[] nums) { int length = nums.length; boolean...
14. ### Algorithm for checking clumps inside an array not working

Homework Statement Say that a "clump" in an array is a series of 2 or more adjacent elements of the same value. Return the number of clumps in the given array. countClumps([1, 2, 2, 3, 4, 4]) → 2 countClumps([1, 1, 2, 1, 1]) → 2 countClumps([1, 1, 1, 1, 1]) → 1 Homework Equations The logic is...
15. ### Making more efficient for loop

Homework Statement Given a string and a non-empty word string, return a string made of each char just before and just after every appearance of the word in the string. Ignore cases where there is no char before or after the word, and a char may be included twice if it is between two words...
16. ### Comp Sci More efficient way of doing this? (java exercise)

Is the bolded a hint ? Since arrays are of fixed lengths. I was just thinking as I was doing these challenges that writing a bunch of if statements felt a little too trivial and not challenging...
17. ### Comp Sci More efficient way of doing this? (java exercise)

Homework Statement Given 2 int arrays, a and b, of any length, return a new array with the first element of each array. If either array is length 0, ignore that array. front11([1, 2, 3], [7, 9, 8]) → [1, 7] front11([1], [2]) → [1, 2] front11([1, 7], []) → [1] Homework Equations The Attempt...
18. ### Comp Sci Trying to understand the inheritance/interface here(java)

group += org.toString() this line will access the x and y positions of the movable objects inside group. Edit: made a misunderstanding. Since group is just an arraylist of movable objects, organisms can be stored into the group object. Essentially I thought any movable object inside group had...
19. ### Comp Sci Trying to understand the inheritance/interface here(java)

Homework Statement package movable; import java.util.ArrayList; import java.util.List; /** * * @author */ public class Group implements Movable { private final List<Movable> groups = new ArrayList<Movable>(); public void addToGroup(Movable movable) { groups.add(movable); } @Override public...
20. ### Comp Sci Keyword search in a hashmap(using retainsAll) in java

If it matters all I changed was instead of having the arraylist of person retainall the elements from entry.getValue() (I'm assuming this shouldn't work because it's just an object, not a list structure) i had simply added them into the arraylist if the condition was fulfilled. Then I...
21. ### Comp Sci Keyword search in a hashmap(using retainsAll) in java

Homework Statement Essentially, I am expected to have a method that can do a keyword search through my hashmap and return respective results. My hashmap is as follows: HashMap<String, Person> phonebook The string as a key is generally the name of the entry. A person object has 3 fields(Name...
22. ### Why does binary search work this way?

Homework Statement public class BinarySearch { public static boolean search(int[] array, int searchedValue) { int beginning = 0; int end = array.length - 1; while (beginning <= end) { int middle = (beginning + end) / 2; if (array[middle] ==...
23. ### Why is my program not returning a percent?

Well that is embarrassing!
24. ### Why is my program not returning a percent?

Homework Statement import java.util.ArrayList; public class Scores { private ArrayList<Integer> examScores = new ArrayList<Integer>(); private int[] howManyScorers; private int accepted; private double acceptedPercent; public Scores(ArrayList<Integer> scores) {...
25. ### Comp Sci Simple cardgame project in Java

I apologize I didn't see your entire message from earlier, and no I have not used switch statements yet. But I do know the general idea behind them from working with C and I don't see any reason why he shouldn't permit me to use them. The JUnit is a test that just runs random values into my code...
26. ### Comp Sci Simple cardgame project in Java

The deadline to hand in this lab was extended to this Saturday as apparently I'm not the only one who was having difficulties(poorly designed lab? :D) With that being said, is there any way I can benefit off of comprehending the JUnit test that my professor uses to grade our labs? My current lab...
27. ### Comp Sci Simple cardgame project in Java

Hmm... would writing more conditions alleviate this issue? Or would that be considered inefficient to do? I'm not too comfortable with java's syntax yet so I'm not sure.
28. ### Comp Sci Simple cardgame project in Java

Ah, I see. So what i can do is write another else if checking if the other cards match? SOmething like: for (int i = 0; i < hand.length(); i = i + 2) { if (hand.charAt(0) == hand.charAt(2)) { r = hand.charAt(0); } else if (hand.charAt(2) ==...
29. ### Comp Sci Simple cardgame project in Java

In regards to the four of the kind, I'm a bit confused. It says that the suit is irrelevant so wouldn't I just have it check at every index seeing if they share the same char?(In this case, start at 0 and work my way up to 8) And then of which it would check if the counter is at 4 and proceed to...
30. ### Comp Sci Simple cardgame project in Java

Going to update the original post with the entirety of the project.
31. ### Comp Sci Simple cardgame project in Java

Homework Statement Hi, so I'm working on a project(part 1) where I am supposed to create a simple card game, under a few requirements. Here are the requirements: 1. Write a method boolean hasFlush(String hand) that checks whether the five-card poker hand given as 10-character string is a...
32. ### Comp Sci Potentially simple java methods HW

Hmm, tbh I don't actually quite understand myself either. But for that matter, maybe this is an example. /** * BankAccount class, foundational code. * * @daniel * @9/21/2016 */ public class BankAccount { double balance; /** * Constructor for objects of class BankAccount...
33. ### Comp Sci Potentially simple java methods HW

I see. That's relatively simple and I just hope he won't deduct marks for using syntax that wasn't demonstrated by him(He just briefly went over everything a beginner Java user should know by the end of the course). I think the main goal of this assignment is to simply return values from methods...
34. ### Comp Sci Potentially simple java methods HW

Thanks for the response. Whilst it would be a relatively easy task for me to do this, the fact of the matter is the professor hasn't really gone into detail... about anything. He hasn't taught any of java's syntax or methods or really anything aside from general theory. Which is why I'm unsure...
35. ### Comp Sci Potentially simple java methods HW

If this helps... this is part 2 of the lab. I'm used to having sample inputs/outputs so I know what is expected of me but I was not given anything here. 1. Write a class Rectangle that has two double fields width and height, and a method void setDimensions(double w, double h) that...
36. ### Comp Sci Potentially simple java methods HW

Homework Statement [/B] So my professor has given this as a lab activity. He has not given any sample outputs, other than these simple instructions. I don't actually understand to what extent I'm to perform this activity to. Write a class BankAccount that contains a double field balance, and...
37. ### Comprehending some C code (simple function calls)

Homework Statement Hi, I have a piece of code that I'm trying to comprehend but I don't understand some aspects. Here is that code: #include <stdio.h> /* function prototype declaration for FindSum */ void FindSum(int, int, int *); int main(void) { int a=2, b=5, c=1, x=3, y=4, z=7; /*...
38. ### C program to calculate area and a few other things

I am really enjoying it right now, as I feel like I am understanding a lot more about the computer as well. Hopefully I can transition into either C++ or java once I've had my fill of C, as it seems like those two are very widely used. The only issue right now I'm imposed with, is that it feels...
39. ### C program to calculate area and a few other things

Alright! Thanks alot. I got it to work the way I want it. I use codeblocks as my C compiler and I don't have that issue where it closes too fast. I have to press a key for it to close the prompt. Just out of curiosity, do you think C is a good program to learn first? I was told otherwise since...
40. ### C program to calculate area and a few other things

Okay thank you for the help! I used spoiler tags as I thought it was neater, but I'll use code tags instead. I'm a little embarrassed I didn't even realize the variables were just spelled incorrectly... The line: perimter_houseFT =(houseleng perimeter_yardFT, perimter_yardM...
41. ### C program to calculate area and a few other things

Mod note: Edited the following to remove spoiler tags and to put code in code tags Homework Statement Hi, currently I have this assignment: Write a program by going through the 6 problem solving steps that reads in the length and width of a rectangular yard in feet, the length and width of a...
42. ### C Programming - First assignment not sure how to approach

Yes, it would literally print out √<value of the variance>. I tried the line of code you gave me and it works. Thanks alot! And yes you're right about the book. I think I'll avoid it for now until I've finished this class(I'm just looking for a variety of books to rely on since it seems...
43. ### C Programming - First assignment not sure how to approach

I apologize for that... I didn't realize the lines weren't identical(you did get all of them except for two though) Thanks for taking the time to read through all of my evaluations. Line 16 = Line 20 Line 21 = Line 25 I have actually written my own piece of code, and for what its worth it...
44. ### C Programming - First assignment not sure how to approach

Alright so I've dabbled along the internet, I've found code online of what I'm looking for(or close to it) and I've been trying to intrepet it from my end. (Since it seems ill have to improvise considering the due date is on thursday...) Again please excuse my ignorance where necessary. I've...
45. ### C Programming - First assignment not sure how to approach

It looks more organized to me haha
46. ### C Programming - First assignment not sure how to approach

Thanks a lot for the replies. Good to know that my intuition isn't worthless and I did need to have some background knowledge. Basically my teacher handed this assignment out yesterday, and it is due this thursday. I do not have a class(I do have a lab tomorrow, however I sincerely doubt she...
47. ### C Programming - First assignment not sure how to approach

Homework Statement Hi, I am currently in a C programming course and i have no background knowledge of programming whatsoever. The professor in my course isn't very good at explaining so I'm a bit lost here. (Please keep in mind, I am NOT asking anyone to do this for me. I would like to know a...